Package overview¶
drf_spectacular.utils¶
- class drf_spectacular.utils.OpenApiCallback(name: str | Promise, path: str, decorator: Callable[[F], F] | Dict[str, Callable[[F], F]] | Dict[str, Any])¶
Bases:
OpenApiSchemaBase
Helper class to bundle a callback definition. This specifies a view on the callee’s side, effectively stating the expectations on the receiving end. Please note that this particular
@extend_schema
instance operates from the perspective of the callback origin, which means thatrequest
specifies the outgoing request.For convenience sake, we assume the callback sends
application/json
and return a200
. If that is not sufficient, you can userequest
andresponses
overloads just as you normally would.- Parameters:
name – Name under which the this callback is listed in the schema.
path – Path on which the callback operation is performed. To reference request body contents, please refer to OpenAPI specification’s key expressions for valid choices.
decorator –
@extend_schema
decorator that specifies the receiving endpoint. In this special context the allowed parameters arerequests
,responses
,summary
,description
,deprecated
.
- class drf_spectacular.utils.OpenApiExample(name: str, value: ~typing.Any = <class 'rest_framework.fields.empty'>, external_value: str = '', summary: str | ~django.utils.functional.Promise = '', description: str | ~django.utils.functional.Promise = '', request_only: bool = False, response_only: bool = False, parameter_only: ~typing.Tuple[str, ~typing.Literal['query', 'path', 'header', 'cookie']] | None = None, media_type: str | None = None, status_codes: ~typing.Sequence[str | int] | None = None)¶
Bases:
OpenApiSchemaBase
Helper class to document a API parameter / request body / response body with a concrete example value.
It is recommended to provide a singular example value, since pagination and list responses are handled by drf-spectacular.
The example will be attached to the operation object where appropriate, i.e. where the given
media_type
,status_code
and modifiers match. Example that do not match any scenario are ignored.media_type will default to ‘application/json’ unless implicitly specified through
OpenApiResponse
status_codes will default to [200, 201] unless implicitly specified through
OpenApiResponse
- class drf_spectacular.utils.OpenApiParameter(name: str, type: ~rest_framework.serializers.Serializer | ~typing.Type[~rest_framework.serializers.Serializer] | ~typing.Type[str | float | bool | bytes | int | dict | ~uuid.UUID | ~decimal.Decimal | ~datetime.datetime | ~datetime.date | ~datetime.time | ~datetime.timedelta | ~ipaddress.IPv4Address | ~ipaddress.IPv6Address] | ~drf_spectacular.types.OpenApiTypes | ~typing.Dict[str, ~typing.Any] = <class 'str'>, location: ~typing.Literal['query', 'path', 'header', 'cookie'] = 'query', required: bool = False, description: str | ~django.utils.functional.Promise = '', enum: ~typing.Sequence[~typing.Any] | None = None, pattern: str | None = None, deprecated: bool = False, style: str | None = None, explode: bool | None = None, default: ~typing.Any = None, allow_blank: bool = True, many: bool | None = None, examples: ~typing.Sequence[~drf_spectacular.utils.OpenApiExample] | None = None, extensions: ~typing.Dict[str, ~typing.Any] | None = None, exclude: bool = False, response: bool | ~typing.Sequence[str | int] = False)¶
Bases:
OpenApiSchemaBase
Helper class to document request query/path/header/cookie parameters. Can also be used to document response headers.
Please note that not all arguments apply to all
location
/type
/direction variations, e.g. path parameters arerequired=True
by definition.For valid
style
choices please consult the OpenAPI specification.
- class drf_spectacular.utils.OpenApiRequest(request: Any = None, encoding: Dict[str, Dict[str, Any]] | None = None, examples: Sequence[OpenApiExample] | None = None)¶
Bases:
OpenApiSchemaBase
Helper class to combine a request object (
Serializer
,OpenApiType
, raw schema, etc.) together with an encoding object and/or examples. Examples can alternatively be provided via@extend_schema
.This class is especially helpful for customizing value encoding for
application/x-www-form-urlencoded
andmultipart/*
. The encoding parameter takes a dictionary with field names as keys and encoding objects as values. Refer to the specification on how to build a valid encoding object.
- class drf_spectacular.utils.OpenApiResponse(response: Any = None, description: str | Promise = '', examples: Sequence[OpenApiExample] | None = None)¶
Bases:
OpenApiSchemaBase
Helper class to bundle a response object (
Serializer
,OpenApiType
, raw schema, etc) together with a response object description and/or examples. Examples can alternatively be provided via@extend_schema
.This class is especially helpful for explicitly describing status codes on a “Response Object” level.
- class drf_spectacular.utils.OpenApiWebhook(name: str | Promise, decorator: Callable[[F], F] | Dict[str, Callable[[F], F]] | Dict[str, Any])¶
Bases:
OpenApiSchemaBase
Helper class to document webhook definitions. A webhook specifies a possible out-of-band request initiated by the API provider and the expected responses from the consumer.
Please note that this particular
@extend_schema
instance operates from the perspective of the webhook origin, which means thatrequest
specifies the outgoing request.For convenience sake, we assume the API provider sends a POST request with a body of type
application/json
and the receiver responds with200
if the event was successfully received.- Parameters:
name – Name under which this webhook is listed in the schema.
decorator –
@extend_schema
decorator that specifies the receiving endpoint. In this special context the allowed parameters arerequests
,responses
,summary
,description
,deprecated
.
- class drf_spectacular.utils.PolymorphicProxySerializer(*args, **kwargs)¶
Bases:
Serializer
This class is to be used with
@extend_schema
to signal a request/response might be polymorphic (accepts/returns data possibly from different serializers). Usage usually looks like this:@extend_schema( request=PolymorphicProxySerializer( component_name='MetaPerson', serializers=[ LegalPersonSerializer, NaturalPersonSerializer, ], resource_type_field_name='person_type', ) ) def create(self, request, *args, **kwargs): return Response(...)
Beware that this is not a real serializer and it will raise an AssertionError if used in that way. It cannot be used in views as
serializer_class
or as field in an actual serializer. It is solely meant for annotation purposes.Also make sure that each sub-serializer has a field named after the value of
resource_type_field_name
(discriminator field). Generated clients will likely depend on the existence of this field.Setting
resource_type_field_name
toNone
will remove the discriminator altogether. This may be useful in certain situations, but will most likely break client generation. Another use-case is explicit control over sub-serializer’smany
attribute. To explicitly control this aspect, you need disable the discriminator withresource_type_field_name=None
as well as disable automatic list handling withmany=False
.It is strongly recommended to pass the
Serializers
as list, and by that let drf-spectacular retrieve the field and handle the mapping automatically. In special circumstances, the field may not available when drf-spectacular processes the serializer. In those cases you can explicitly state the mapping with{'legal': LegalPersonSerializer, ...}
, but it is then your responsibility to have a valid mapping.It is also permissible to provide a callable with no parameters for
serializers
, such as a lambda that will return an appropriate list or dict when evaluated.- property data¶
- property serializers¶
- to_internal_value(data)¶
Dict of native values <- Dict of primitive datatypes.
- to_representation(instance)¶
Object instance -> Dict of primitive datatypes.
- drf_spectacular.utils.extend_schema(operation_id: str | None = None, parameters: ~typing.Sequence[~drf_spectacular.utils.OpenApiParameter | ~rest_framework.serializers.Serializer | ~typing.Type[~rest_framework.serializers.Serializer]] | None = None, request: ~typing.Any = <class 'rest_framework.fields.empty'>, responses: ~typing.Any = <class 'rest_framework.fields.empty'>, auth: ~typing.Sequence[str] | None = None, description: str | ~django.utils.functional.Promise | None = None, summary: str | ~django.utils.functional.Promise | None = None, deprecated: bool | None = None, tags: ~typing.Sequence[str] | None = None, filters: bool | None = None, exclude: bool | None = None, operation: ~typing.Dict[str, ~typing.Any] | None = None, methods: ~typing.Sequence[str] | None = None, versions: ~typing.Sequence[str] | None = None, examples: ~typing.Sequence[~drf_spectacular.utils.OpenApiExample] | None = None, extensions: ~typing.Dict[str, ~typing.Any] | None = None, callbacks: ~typing.Sequence[~drf_spectacular.utils.OpenApiCallback] | None = None, external_docs: ~typing.Dict[str, str] | str | None = None) Callable[[F], F] ¶
Decorator mainly for the “view” method kind. Partially or completely overrides what would be otherwise generated by drf-spectacular.
- Parameters:
operation_id – replaces the auto-generated operation_id. make sure there are no naming collisions.
parameters – list of additional or replacement parameters added to the auto-discovered fields.
responses –
replaces the discovered Serializer. Takes a variety of inputs that can be used individually or combined
Serializer
classSerializer
instance (e.g.Serializer(many=True)
for listings)basic types or instances of
OpenApiTypes
OpenApiResponse
for bundling any of the other choices together with either a dedicated response description and/or examples.PolymorphicProxySerializer
for signaling that the operation may yield data from different serializers depending on the circumstances.dict
with status codes as keys and one of the above as values. Additionally in this case, it is also possible to provide a raw schema dict as value.dict
with tuples (status_code, media_type) as keys and one of the above as values. Additionally in this case, it is also possible to provide a raw schema dict as value.
request –
replaces the discovered
Serializer
. Takes a variety of inputsSerializer
class/instancebasic types or instances of
OpenApiTypes
PolymorphicProxySerializer
for signaling that the operation accepts a set of different types of objects.dict
with media_type as keys and one of the above as values. Additionally, in this case, it is also possible to provide a raw schema dict as value.
auth – replace discovered auth with explicit list of auth methods
description – replaces discovered doc strings
summary – an optional short summary of the description
deprecated – mark operation as deprecated
tags – override default list of tags
filters – ignore list detection and forcefully enable/disable filter discovery
exclude – set True to exclude operation from schema
operation – manually override what auto-discovery would generate. you must provide a OpenAPI3-compliant dictionary that gets directly translated to YAML.
methods – scope extend_schema to specific methods. matches all by default.
versions – scope extend_schema to specific API version. matches all by default.
examples – attach request/response examples to the operation
extensions – specification extensions, e.g.
x-badges
,x-code-samples
, etc.callbacks – associate callbacks with this endpoint
external_docs – Link external documentation. Provide a dict with an “url” key and optionally a “description” key. For convenience, if only a string is given it is treated as the URL.
- Returns:
- drf_spectacular.utils.extend_schema_field(field: Serializer | Type[Serializer] | Field | Type[Field] | OpenApiTypes | Dict[str, Any] | Type[str | float | bool | bytes | int | dict | UUID | Decimal | datetime | date | time | timedelta | IPv4Address | IPv6Address], component_name: str | None = None) Callable[[F], F] ¶
Decorator for the “field” kind. Can be used with
SerializerMethodField
(annotate the actual method) or with customserializers.Field
implementations.If your custom serializer field base class is already the desired type, decoration is not necessary. To override the discovered base class type, you can decorate your custom field class.
Always takes precedence over other mechanisms (e.g. type hints, auto-discovery).
- Parameters:
field – accepts a
Serializer
,OpenApiTypes
or rawdict
component_name – signals that the field should be broken out as separate component
- drf_spectacular.utils.extend_schema_serializer(many: bool | None = None, exclude_fields: Sequence[str] | None = None, deprecate_fields: Sequence[str] | None = None, examples: Sequence[OpenApiExample] | None = None, extensions: Dict[str, Any] | None = None, component_name: str | None = None) Callable[[F], F] ¶
Decorator for the “serializer” kind. Intended for overriding default serializer behaviour that cannot be influenced through
@extend_schema
.- Parameters:
many – override how serializer is initialized. Mainly used to coerce the list view detection heuristic to acknowledge a non-list serializer.
exclude_fields – fields to ignore while processing the serializer. only affects the schema. fields will still be exposed through the API.
deprecate_fields – fields to mark as deprecated while processing the serializer.
examples – define example data to serializer.
extensions – specification extensions, e.g.
x-is-dynamic
, etc.component_name – override default class name extraction.
- drf_spectacular.utils.extend_schema_view(**kwargs) Callable[[F], F] ¶
Convenience decorator for the “view” kind. Intended for annotating derived view methods that are are not directly present in the view (usually methods like
list
orretrieve
). Spares you from overriding methods likelist
, only to perform a super call in the body so that you have have something to attach@extend_schema
to.This decorator also takes care of safely attaching annotations to derived view methods, preventing leakage into unrelated views.
This decorator also supports custom DRF
@action
with the method name as the key.- Parameters:
kwargs – method names as argument names and
@extend_schema
calls as values
- drf_spectacular.utils.inline_serializer(name: str, fields: Dict[str, Field], **kwargs) Serializer ¶
A helper function to create an inline serializer. Primary use is with
@extend_schema
, where one needs an implicit one-off serializer that is not reflected in an actual class.- Parameters:
name – name of the
fields – dict with field names as keys and serializer fields as values
kwargs – optional kwargs for serializer initialization
drf_spectacular.types¶
- class drf_spectacular.types.OpenApiTypes(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Basic types known to the OpenAPI specification or at least common format extension of it.
Use
BYTE
for base64-encoded data wrapped in a stringUse
BINARY
for raw binary dataUse
OBJECT
for arbitrary free-form object (usually adict
)
- NUMBER = 1¶
Converted to
{"type": "number"}
.
- DOUBLE = 3¶
Converted to
{"type": "number", "format": "double"}
.
- BYTE = 6¶
Converted to
{"type": "string", "format": "byte"}
. Use this for base64-encoded data wrapped in a string.
- BINARY = 7¶
Converted to
{"type": "string", "format": "binary"}
. Equivalent tobytes
. Use this for raw binary data.
- PASSWORD = 8¶
Converted to
{"type": "string", "format": "password"}
.
- INT32 = 10¶
Converted to
{"type": "integer", "format": "int32"}
.
- INT64 = 11¶
Converted to
{"type": "integer", "format": "int64"}
.
- URI = 13¶
Converted to
{"type": "string", "format": "uri"}
.
- URI_REF = 14¶
Converted to
{"type": "string", "format": "uri-reference"}
.
- URI_TPL = 15¶
Converted to
{"type": "string", "format": "uri-template"}
.
- IRI = 16¶
Converted to
{"type": "string", "format": "iri"}
.
- IRI_REF = 17¶
Converted to
{"type": "string", "format": "iri-reference"}
.
- IP4 = 18¶
Converted to
{"type": "string", "format": "ipv4"}
. Equivalent toIPv4Address
.
- IP6 = 19¶
Converted to
{"type": "string", "format": "ipv6"}
. Equivalent toIPv6Address
.
- HOSTNAME = 20¶
Converted to
{"type": "string", "format": "hostname"}
.
- IDN_HOSTNAME = 21¶
Converted to
{"type": "string", "format": "idn-hostname"}
.
- DECIMAL = 22¶
Converted to
{"type": "number", "format": "double"}
. The same asDOUBLE
. Equivalent toDecimal
.
- DURATION = 26¶
Converted to
{"type": "string", "format": "duration"}
. Equivalent totimedelta
. Expressed according to ISO 8601.
- EMAIL = 27¶
Converted to
{"type": "string", "format": "email"}
.
- IDN_EMAIL = 28¶
Converted to
{"type": "string", "format": "idn-email"}
.
- JSON_PTR = 29¶
Converted to
{"type": "string", "format": "json-pointer"}
.
- JSON_PTR_REL = 30¶
Converted to
{"type": "string", "format": "relative-json-pointer"}
.
- REGEX = 31¶
Converted to
{"type": "string", "format": "regex"}
.
- OBJECT = 32¶
Converted to
{"type": "object", ...}
. Use this for arbitrary free-form objects (usually adict
). TheadditionalProperties
item is added depending on theGENERIC_ADDITIONAL_PROPERTIES
setting.
- ANY = 34¶
Converted to
{}
which sets no type and format. Equivalent totyping.Any
.
drf_spectacular.views¶
- class drf_spectacular.views.SpectacularAPIView(**kwargs)¶
Bases:
APIView
- authentication_classes = [<class 'rest_framework.authentication.SessionAuthentication'>, <class 'rest_framework.authentication.BasicAuthentication'>]¶
- generator_class¶
alias of
SchemaGenerator
- get(request, *args, **kwargs)¶
- permission_classes = [<class 'rest_framework.permissions.AllowAny'>]¶
- renderer_classes = [<class 'drf_spectacular.renderers.OpenApiYamlRenderer'>, <class 'drf_spectacular.renderers.OpenApiYamlRenderer2'>, <class 'drf_spectacular.renderers.OpenApiJsonRenderer'>, <class 'drf_spectacular.renderers.OpenApiJsonRenderer2'>]¶
- class drf_spectacular.views.SpectacularJSONAPIView(**kwargs)¶
Bases:
SpectacularAPIView
- renderer_classes = [<class 'drf_spectacular.renderers.OpenApiJsonRenderer'>, <class 'drf_spectacular.renderers.OpenApiJsonRenderer2'>]¶
- class drf_spectacular.views.SpectacularRedocView(**kwargs)¶
Bases:
APIView
- authentication_classes = [<class 'rest_framework.authentication.SessionAuthentication'>, <class 'rest_framework.authentication.BasicAuthentication'>]¶
- get(request, *args, **kwargs)¶
- permission_classes = [<class 'rest_framework.permissions.AllowAny'>]¶
- renderer_classes = [<class 'rest_framework.renderers.TemplateHTMLRenderer'>]¶
- class drf_spectacular.views.SpectacularSwaggerOauthRedirectView(**kwargs)¶
Bases:
RedirectView
A view that serves the SwaggerUI oauth2-redirect.html file so that SwaggerUI can authenticate itself using Oauth2
This view should be served as
./oauth2-redirect.html
relative to the SwaggerUI itself. If that is not possible, this views absolute url can also be set via theSPECTACULAR_SETTINGS.SWAGGER_UI_SETTINGS.oauth2RedirectUrl
django settings.- get_redirect_url(*args, **kwargs)¶
Return the URL redirect to. Keyword arguments from the URL pattern match generating the redirect request are provided as kwargs to this method.
- class drf_spectacular.views.SpectacularSwaggerSplitView(**kwargs)¶
Bases:
SpectacularSwaggerView
Alternate Swagger UI implementation that separates the html request from the javascript request to cater to web servers with stricter CSP policies.
- get(request, *args, **kwargs)¶
- class drf_spectacular.views.SpectacularSwaggerView(**kwargs)¶
Bases:
APIView
- authentication_classes = [<class 'rest_framework.authentication.SessionAuthentication'>, <class 'rest_framework.authentication.BasicAuthentication'>]¶
- get(request, *args, **kwargs)¶
- permission_classes = [<class 'rest_framework.permissions.AllowAny'>]¶
- renderer_classes = [<class 'rest_framework.renderers.TemplateHTMLRenderer'>]¶
- class drf_spectacular.views.SpectacularYAMLAPIView(**kwargs)¶
Bases:
SpectacularAPIView
- renderer_classes = [<class 'drf_spectacular.renderers.OpenApiYamlRenderer'>, <class 'drf_spectacular.renderers.OpenApiYamlRenderer2'>]¶
drf_spectacular.extensions¶
- class drf_spectacular.extensions.OpenApiAuthenticationExtension(target)¶
Bases:
OpenApiGeneratorExtension
[OpenApiAuthenticationExtension
]Extension for specifying authentication schemes.
The common use-case usually consists of setting a
name
string and returning a dict fromget_security_definition
. To model a group of headers that go together, set a list of names and return a corresponding list of definitions fromget_security_definition
.The view class is available via
auto_schema.view
, while the original authentication class can be accessed viaself.target
. If you want to override an included extension, be sure to set a higher matching priority by setting the class attributepriority = 1
or higher.get_security_requirement is expected to return a dict with security object names as keys and a scope list as value (usually just []). More than one key in the dict means that each entry is required (AND). If you need alternate variations (OR), return a list of those dicts instead.
get_security_definition()
is expected to return a valid OpenAPI security scheme object
- class drf_spectacular.extensions.OpenApiFilterExtension(target)¶
Bases:
OpenApiGeneratorExtension
[OpenApiFilterExtension
]Extension for specifying a list of filter parameters for a given
FilterBackend
.The original filter class object can be accessed via
self.target
. The attached view is accessible viaauto_schema.view
.get_schema_operation_parameters()
is expected to return either an empty list or a list of valid raw OpenAPI parameter objects. Usingdrf_spectacular.plumbing.build_parameter_type
is recommended to generate the appropriate raw dict objects.
- class drf_spectacular.extensions.OpenApiSerializerExtension(target)¶
Bases:
OpenApiGeneratorExtension
[OpenApiSerializerExtension
]Extension for replacing an insufficient or specifying an unknown Serializer schema.
The existing implementation of
map_serializer()
will generate the same result as drf-spectacular would. Either augment or replace the generated schema. The view instance is available viaauto_schema.view
, while the original serializer can be accessed viaself.target
.map_serializer()
is expected to return a valid OpenAPI schema object.- get_identity(auto_schema: AutoSchema, direction: Literal['request', 'response']) Any ¶
return anything to compare instances of target. Target will be used by default.
- get_name(auto_schema: AutoSchema, direction: Literal['request', 'response']) str | None ¶
return str for overriding default name extraction
- class drf_spectacular.extensions.OpenApiSerializerFieldExtension(target)¶
Bases:
OpenApiGeneratorExtension
[OpenApiSerializerFieldExtension
]Extension for replacing an insufficient or specifying an unknown SerializerField schema.
To augment the default schema, you can get what drf-spectacular would generate with
auto_schema._map_serializer_field(self.target, direction, bypass_extensions=True)
. and edit the returned schema at your discretion. Beware that this may still emit warnings, in which case manual construction is advisable.map_serializer_field()
is expected to return a valid OpenAPI schema object.
- class drf_spectacular.extensions.OpenApiViewExtension(target)¶
Bases:
OpenApiGeneratorExtension
[OpenApiViewExtension
]Extension for replacing discovered views with a more schema-appropriate/annotated version.
view_replacement()
is expected to return a subclass ofAPIView
(which includesViewSet
et al.). The discovered original view instance can be accessed withself.target
and be subclassed if desired.- abstract view_replacement() Type[APIView] ¶
drf_spectacular.hooks¶
- drf_spectacular.hooks.postprocess_schema_enum_id_removal(result, generator, **kwargs)¶
Iterative modifying approach to scanning the whole schema and removing the temporary helper ids that allowed us to distinguish similar enums.
- drf_spectacular.hooks.postprocess_schema_enums(result, generator, **kwargs)¶
simple replacement of Enum/Choices that globally share the same name and have the same choices. Aids client generation to not generate a separate enum for every occurrence. only takes effect when replacement is guaranteed to be correct.
- drf_spectacular.hooks.preprocess_exclude_path_format(endpoints, **kwargs)¶
preprocessing hook that filters out {format} suffixed paths, in case format_suffix_patterns is used and {format} path params are unwanted.
drf_spectacular.openapi¶
- class drf_spectacular.openapi.AutoSchema¶
Bases:
ViewInspector
- get_auth() List[Dict[str, Any]] ¶
Obtains authentication classes and permissions from view. If authentication is known, resolve security requirement for endpoint and security definition for the component section. For custom authentication subclass
OpenApiAuthenticationExtension
.
- get_callbacks() List[OpenApiCallback] ¶
override this for custom behaviour
- get_examples() List[OpenApiExample] ¶
override this for custom behaviour
- get_operation(path: str, path_regex: str, path_prefix: str, method: str, registry: ComponentRegistry) Dict[str, Any] | None ¶
- get_override_parameters() List[OpenApiParameter | Serializer | Type[Serializer]] ¶
override this for custom behaviour
- get_response_serializers() Serializer | Type[Serializer] | None ¶
override this for custom behaviour
- get_serializer_name(serializer: Serializer, direction: Literal['request', 'response']) str ¶
override this for custom behaviour
- method_mapping = {'delete': 'destroy', 'get': 'retrieve', 'patch': 'partial_update', 'post': 'create', 'put': 'update'}¶
drf_spectacular.contrib.django_filters¶
- class drf_spectacular.contrib.django_filters.DjangoFilterExtension(target)¶
Bases:
OpenApiFilterExtension
Extensions that specifically deals with
django-filter
fields. The introspection attempts to estimate the underlying model field types to generate filter types.However, there are under-specified filter fields for which heuristics need to be performed. This serves as an explicit list of all partially-handled filter fields:
AllValuesFilter
: skip choices to prevent DB queryAllValuesMultipleFilter
: skip choices to prevent DB query, multi handled thoughChoiceFilter
: enum handled, type under-specifiedDateRangeFilter
: N/ALookupChoiceFilter
: N/AModelChoiceFilter
: enum handledModelMultipleChoiceFilter
: enum, multi handledMultipleChoiceFilter
: enum, multi handledRangeFilter
: min/max handled, type under-specifiedTypedChoiceFilter
: enum handledTypedMultipleChoiceFilter
: enum, multi handled
In case of warnings or incorrect filter types, you can manually override the underlying field type with a manual
extend_schema_field
decoration. Alternatively, if you have a filter method for your filter field, you can attachextend_schema_field
to that filter method.class SomeFilter(FilterSet): some_field = extend_schema_field(OpenApiTypes.NUMBER)( RangeFilter(field_name='some_manually_annotated_field_in_qs') )