SyneticNL / Hyral

Hypermedia oriented Resource API Layer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Move Resource creation from responseNormalizer to repository to enable use for api's that don't return type

jurcello opened this issue · comments

Some api's like django rest framework don't include the resource type in the returned data by default. At this moment it is therefore not possible to create the proper responseNormalizer.
In my opinion the responseNormalizer should return items where the minimum required structure is data and an id.

Does it follow JSON:API specification or is it another format? If it's JSON:API the implementation for the server is incorrect, the spec states the id and type properties are mandatory.

https://jsonapi.org/format/#document-resource-objects

It doesn't follow that specification. The point is that there are a lot of api's that doesn't adhere to the JSON:API specification. If support for that kind of API's should be possible, than resource creation has to be moved to a location where the resource type is known.

Discussed offline:

  • The implementation of transformResponse will be changed slightly to not beeing called via Axios but directly in a .then() so that the repository can be added to the function call as the fourth parameter (to maintain BC)

Will be part of the 1.2 release