tfranzel / drf-spectacular

Sane and flexible OpenAPI 3 schema generation for Django REST framework.
https://drf-spectacular.readthedocs.io
BSD 3-Clause "New" or "Revised" License
2.34k stars 259 forks source link

GIS source lookup with hops and geo_field not working #989

Open masb3 opened 1 year ago

masb3 commented 1 year ago

Describe the bug GeometryField in restframework_gis.serializers.GeoFeatureModelSerializer with source lookup fails with KeyError in drf_spectacular/contrib/rest_framework_gis.py", line 125, in map_geo_field. Same issue as https://github.com/tfranzel/drf-spectacular/issues/813 , but serializer GeoFeatureModelSerializer.

To Reproduce

class AssetSerializer(GeoFeatureModelSerializer):
    aoi = GeometryField(source="aoi.geometry")
    class Meta:
           geo_field = "aoi"

At the moment I fixed by replacing https://github.com/tfranzel/drf-spectacular/blob/ea31d9062ede9e83a01021e7a80c3a7fbbecbad1/drf_spectacular/contrib/rest_framework_gis.py#L125 with model_field = follow_field_source(serializer.Meta.model, field.source.split('.'))

tfranzel commented 1 year ago

I will have a look at this.

madisvain commented 9 months ago

@tfranzel could we provide any help to get this change into a release. Possibly a PR would help?

We have been using this implementation without issues in production for quite a while.

madisvain commented 3 months ago

@tfranzel trying to raise this topic once more - if there is any help I could provide then please let me know. I'd be happy to help with getting this fix in.

tfranzel commented 3 months ago

Sry this fell off the wagon @madisvain but this is not usable like that (commits on a fork). Please open a proper PR on the main repo. Make sure this is covered by the tests and do not update versions or the changelog, just the GIS change.

I will do a speedy review then.