rest_framework_dso.openapi module

Improvements for the OpenAPI schema output.

While django-rest-framework provides OpenAPI support, it’s very limited. That functionality is greatly extended by the use of drf-spectacular and the classes in this module. This also inludes exposing geometery type classes in the OpenAPI schema.

class rest_framework_dso.openapi.DSOAutoSchema

Bases: AutoSchema

Default schema for API views that don’t define a schema attribute.

get_description()

Override what _get_viewset_api_docs() does.

get_filter_backends()

override this for custom behaviour

get_override_parameters()

Expose the DSO-specific HTTP headers in all API methods.

get_tags() list[str]

Auto-generate tags based on the path, take last bit of path.

class rest_framework_dso.openapi.DSOSchemaGenerator(*args, **kwargs)

Bases: SchemaGenerator

Extended OpenAPI schema generator, that provides:

  • Override OpenAPI parts (via: schema_overrides)

  • GeoJSON components (added to components.schemas).

drf_spectacular also provides ‘components’ which DRF doesn’t do.

get_schema(request=None, public=False)

Improved schema generation, include more OpenAPI fields

has_view_permissions(*args, **kwargs)

Schemas are public, so this is always true.

schema_overrides = {}

Allow to override the schema