-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Openapi schema generation does not support serializers not subclassing GeoFeatureModelSerializer #257
Comments
@dhaval-mehta what do you think? |
I was able to fix this. The diff is pretty simple, but I haven't looked into tests yet. I'll follow up with a PR soon. |
The intial implementation of schema generation only supported serializers which subclassed GeoFeatureModel*Serializer. This meant that models which have standalone GeometryFields would not properly generate a schema. This change adds support for that use case. Fixes openwisp#257
@AndrewGuenther Can you please share the serializer as well? Does your serializer class extends |
No, my serializer does not extend from core_api.models.StoredRaster import StoredRaster
from rest_framework import serializers
class StoredRasterSerializer(serializers.ModelSerializer):
class Meta:
model = StoredRaster
fields = '__all__' |
I got your point. |
I had some medical emergency and because of it, I couldn’t pick this task. Sorry for the inconvenience caused. I will try to complete this in the current week only. |
I went ahead and submitted the change that I have. I just couldn't figure out how to test it properly. Would love some feedback on that. |
I went ahead and added a test that covers this, but still would like feedback if it's the preferred way. |
I will review this PR. |
…#257 The intial implementation of schema generation only supported serializers which subclassed GeoFeatureModel*Serializer. This meant that models which have standalone GeometryFields would not properly generate a schema. This change adds support for that use case. Closes openwisp#257
…#257 The intial implementation of schema generation only supported serializers which subclassed GeoFeatureModel*Serializer. This meant that models which have standalone GeometryFields would not properly generate a schema. This change adds support for that use case. Closes openwisp#257
The intial implementation of schema generation only supported serializers which subclassed GeoFeatureModel*Serializer. This meant that models which have standalone GeometryFields would not properly generate a schema. This change adds support for that use case. Closes #257
I have a pretty simple model:
If I try to now generate a schema of this model, it will declare the
footprint
field as a string type, rather than the GeoJSON representation that the API would actually return. This causes clients to fail type validation on responses.You can see that the schema generation logic explicitly checks for this serializer in both of these places:
https://github.com/openwisp/django-rest-framework-gis/blob/master/rest_framework_gis/schema.py#L162-L169
https://github.com/openwisp/django-rest-framework-gis/blob/master/rest_framework_gis/schema.py#L109-L113
The logic for
map_field
should be adapted to also handleGeometryField
sThe text was updated successfully, but these errors were encountered: