Skip to content

Schema support for serializer_class with @api_view #5759

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

Closed
blueyed opened this issue Jan 22, 2018 · 3 comments
Closed

Schema support for serializer_class with @api_view #5759

blueyed opened this issue Jan 22, 2018 · 3 comments

Comments

@blueyed
Copy link
Contributor

blueyed commented Jan 22, 2018

The WrappedAPIView returned/created by the @api_view decorator handles decorators like @renderer_classes, but not @serializer_class.

Having information about the (input) serializer appears to be important for generating schemas however.

I think this would have helped with the underlying issue that #4285 fixed, and is maybe also what #5630 (comment) refers to?!

@carltongibson
Copy link
Collaborator

Hey @blueyed. This is just the division between APIView and GenericAPIView. The api_view decorator handles the former, but not the latter. (And serializer_class is defined on GenericAPIView...)

The comment you link (I was wondering where that was...) is looking for more API (on APIView) to add an extension point for dynamic view inspector class selection, rather than @ api_view's support (or not) of the GenericAPIView API.

@blueyed
Copy link
Contributor Author

blueyed commented Jan 22, 2018

What do you suggest then to get proper documentation / schema?
Not using @api_view, or create a custom decorator that would use GenericAPIView instead?

@carltongibson
Copy link
Collaborator

You'd need to pass an AutoSchema subclass that knew about your view. Either that or, yes, use GenericAPIView, probably just as a class-based view.

You can use any means you like, but the built-in support leverages GenericAPIView.

@rpkilby rpkilby changed the title Support for serializer_class with @api_view Schema support for serializer_class with @api_view Jan 22, 2018
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

2 participants