Open vladmunteanu opened 5 years ago
@vladmunteanu did you tried to declare your id field as Str
in your schema?
class SomeSchema(Schema):
class Meta:
type_ = 'some-type'
self_view = 'v1.some_type_details'
self_view_kwargs = {'id': '<id>'}
self_view_many = 'v1.some_type_list'
inflect = dasherize
strict = True
ordered = True
id = fields.Str(dump_only=True)
[…]
@kumy Yes, the id is already a fields.Str. LE: this should be enforced by the library anyway, since the spec requires it.
To be clear, this doesn't happen for a get on /some-resource, but only for relationships returned by the ResourceRelationship
. I suspect this is because there is no cast done here: https://github.com/miLibris/flask-rest-jsonapi/blob/b4cb5576b75ffaf6463abb8952edc8839b03463f/flask_rest_jsonapi/data_layers/alchemy.py#L290
According to JSON:API, the
id
field should always be a string, but this isn't the case when fetching relationships throughSqlalchemyDataLayer
.I suspect the problem originates here: https://github.com/miLibris/flask-rest-jsonapi/blob/b4cb5576b75ffaf6463abb8952edc8839b03463f/flask_rest_jsonapi/data_layers/alchemy.py#L256
@akira-dev I would be happy to contribute with a pull request if you consider this correct.