FriendsOfCake / crud-json-api

Build advanced JSON API Servers with almost no code.
https://crud-json-api.readthedocs.io/
MIT License
56 stars 32 forks source link

Why are integer ids converted to strings in relationships (but not elsewhere)? #124

Closed geoidesic closed 4 years ago

geoidesic commented 4 years ago

Given an entity enquiry which is related to person via person_id column. When storing a new enquiry the related person_id is stored to the database as an integer. In the JSONAPI return, any attributes that are integer values will be returned as Integer type, however relationships will return integer ids as String type.

Is this necessary due to the JSONAPI spec?

To my mind it's a bug because you should not lose type information where it's possible to retain it.

geoidesic commented 4 years ago

Any idea whether this is handled by crud-json-api or neomerx? I'm wondering if this issue is on the correct repo.

dakota commented 4 years ago

The type casting is done by crud-json-api as it is enforced by the neomerx interfaces. The reason is that the JSON:API spec explicitly requires id to be string.