drf-spectacular

drf-spectacular is an excellent library for OpenAPI 3.x schema generation from your django-rest-framework endpoints.

The utilities documented here provide additional tooling or fixes/workarounds for those generated schemas.

Hooks

Provide hooks for drf-spectacular schema post-processing.

Some generated schemas by drf-spectacular contain issues that don’t pass linter validation or emit warnings. The hooks in this module address these.

maykin_common.drf_spectacular.hooks.remove_invalid_url_defaults(result, *args, **kwargs)

Fix URLField(default="") schema generation.

An empty string does not satisfy the format: uri validation, and schema validation tools can trip on this.

The majority of the code here is inspired by the built in drf_spectacular.hooks.postprocess_schema_enums() hook.

Todo

contribute a fix to upstream library.