Use Serializer in extend_schema.parameters (use serializer as OpenApiParameter?)
See original GitHub issueHi This is actually a question, I did a lot of searches and can’t find the suggested way to use serializer as OpenApiParameter: Currently I am using this way:
extend_schema(
operation_id="op1",
description="",
tags=["tag1"],
parameters=[MyQueryParamSerializer], <-
request=MyRequestBodySerializer,
responses={
status.HTTP_200_OK: OpenApiResponse()
}
)
This works for 0.16. But with the new version release three days ago (0.17).
It will start giving warnings starting tag 0.17.0 like:
error: List item 0 has incompatible type "Type[MyQueryParamSerializer]"; expected "OpenApiParameter"
So my question would be what’s the preferred way to use Serializer(s) as OpenApiParameter(s)? Thanks for the answering and help!
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
Workflow & schema customization - drf-spectacular
Step 1: queryset and serializer_class. Introspection heavily relies on those two attributes. get_serializer_class() and get_serializer() are also used if ...
Read more >drf-spectacular: Add OpenApiResponse to a serializer-less ...
If you don't have a Serializer , you can use inline_serializer : from drf_spectacular.utils import extend_schema, OpenApiParameter, ...
Read more >Parameter Serialization - Swagger
OpenAPI serialization rules are based on a subset of URI template patterns defined by RFC 6570. Tool implementers can use existing URI template...
Read more >drf-spectacular - PyPI
request/response serializer override (with status codes) ... Install using pip… ... then add drf-spectacular to installed apps in settings.py
Read more >Schemas - Django REST framework
API schemas are a useful tool that allow for a range of use cases, ... relies on the relevant attributes and methods of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
hi @janneronkko sry for the inconvenience. i’ll do it very soon. i need to look at 2 other issues first. probably tomorrow.
We were also hit by this issue after updating our dependencies.
I blacklisted the 0.17.0 version in our setup.py so that we won’t get that version.
Could you release 0.17.1 as soon as possible so people would not need to spend time on finding out why they get type errors after updating drf-spectacular?