Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Serializer in a View #487

Closed
efe opened this issue Nov 4, 2019 · 3 comments
Closed

Multiple Serializer in a View #487

efe opened this issue Nov 4, 2019 · 3 comments

Comments

@efe
Copy link

efe commented Nov 4, 2019

Hello,

A view returns different serializers by looking the query parameter.

def get_serializer_class(self):
    bundle_type = self.request.query_params.get('bundle_type')
    if bundle_type == "large":
        return LargeSerializer
    else:
        return SmallSerializer

How should I document this?

@PaulWay
Copy link
Contributor

PaulWay commented Nov 22, 2019

I think the problem is that that wouldn't be a valid OpenAPI / Swagger spec. AFAICS the spec can't change what type it outputs based on any knowledge of the actual query.

@davidmgvaz
Copy link

This is supported in OpenAPI 3.0:

OAI/OpenAPI-Specification#270 (comment)

Just need to wait for drf-yasg to support 3.0

@efe
Copy link
Author

efe commented Dec 18, 2019

@davidmgvaz thank you! i look forward for the new release. :)

@efe efe closed this as completed Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants