question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use Serializer in extend_schema.parameters (use serializer as OpenApiParameter?)

See original GitHub issue

Hi 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:closed
  • Created 2 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
tfranzelcommented, Jun 10, 2021

hi @janneronkko sry for the inconvenience. i’ll do it very soon. i need to look at 2 other issues first. probably tomorrow.

0reactions
janneronkkocommented, Jun 10, 2021

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found