django-rest-framework-gis icon indicating copy to clipboard operation
django-rest-framework-gis copied to clipboard

Using the BBOX filter creates invalid Open API Schema

Open tomdtp opened this issue 2 years ago • 2 comments

I have an API view using a BBOX filter:

class ProtectedAreaGeoJSONViewSet(ListAPIView):
    schema = AutoSchema(operation_id_base="ProtectedAreaGeoJSON")

    queryset = Geodata.objects.all()
    bbox_filter_field = "geometry"
    filter_backends = (InBBoxFilter,)

This leads to the generation of this OpenAPI Schema entry:

      - name: in_bbox
        required: false
        in: query
        description: 'Specify a bounding box as filter: in_bbox=min_lon,min_lat,max_lon,max_lat'
        schema:
          type: array
          items:
            type: float
          minItems: 4
          maxItems: 4
          example:
          - 0
          - 0
          - 10
          - 10
        style: form
        explode: false

Which is incorrect, as the type of the array entries should be number and not float.

Any ideas why this is happening?

tomdtp avatar Nov 23 '23 12:11 tomdtp

It looks like this was fixed in https://github.com/openwisp/django-rest-framework-gis/commit/c354c21e8c3c65c9df9e0d9fec726d4a50a51d1a 2 days after the latest release 🤦

Any plans to cut a point release soon or for this? It breaks the openapi schema for this filter as well as the DistanceToPointFilter.

davidcroda avatar Jan 16 '25 20:01 davidcroda

@nemesifier any plans to do a point release with this fix in it? It would be super helpful, I am currently overriding the class just to monkey patch this api schema bug.

davidcroda avatar Jan 16 '25 20:01 davidcroda