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

Is it possible to use drf-spectacular for generating OpenAPI schema for native django (non-DRF) views? #931

Closed
microHoffman opened this issue Feb 6, 2023 · 2 comments

Comments

@microHoffman
Copy link

Hello,
since DRF does not support async views, we are writing some async views using native Django views: from django.views import View. However it seems like these views does not get recognized by drf-spectacular when generating the schema, even when using the @extend_schema on them. This gets me to the question - is it even possible to generate an OpenAPI schema for the native django views, or does it support only DRF views? Is there any workaround I could use?
Thanks!

@microHoffman microHoffman changed the title Is it possible to use this with native django views? Is it possible to use drf-spectacular for generating OpenAPI schema for native django (non-DRF) views? Feb 6, 2023
@tfranzel
Copy link
Owner

tfranzel commented Feb 6, 2023

Hi, yeah that does not work. All the concepts that spectacular relies on do come from DRF. There is no workaround currently and there will most likely never be one.

Django has no concept of renderer, parser, permission,authentication, serializer or viewset classes. All of our parsing is based on that. Even if we would allow @extend_schema on plain django views, there would still be a lot of necessary information missing. And to make it even worse, all of our mechanics are based on subclassing AutoSchema, which is solely a DRF feature.

tl;dr: DRF and drf-spectacular are so interwoven that drf-spectacular would simply make very little to no sense without DRF.

@microHoffman
Copy link
Author

Thank for your response:) Closing this now.

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