Skip to content

Openapi schema generation does not support serializers not subclassing GeoFeatureModelSerializer #257

Closed
@AndrewGuenther

Description

I have a pretty simple model:

from django.contrib.gis.db import models

class StoredRaster(models.Model):
   file_arn = models.CharField(max_length=1024, null=True)
   footprint = models.PolygonField(srid=4326, null=True)

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 handle GeometryFields

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions