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

Cannot generate interface documentation for viewsets specific interface when “”versioning_class = NamespaceVersioning” is added to view #1068

Closed
Cloverxue opened this issue Sep 7, 2023 · 4 comments

Comments

@Cloverxue
Copy link

Describe the bug
Cannot generate interface documentation for viewsets specific interface when “”versioning_class = NamespaceVersioning” is added to view
The interface document for MyViewSet disappears when adding “versioning_class = NamespaceVersioning” to MyViewSet,
for example:
from rest_framework.versioning import NamespaceVersioning
class MyViewSet(mixins.ListModelMixin, viewsets.GenericViewSet):
versioning_class = NamespaceVersioning

To Reproduce
A:
class MyViewSet(mixins.ListModelMixin, viewsets.GenericViewSet):
pass
B:
class MyViewSet(mixins.ListModelMixin, viewsets.GenericViewSet):
versioning_class = NamespaceVersioning
A can generate interface documents normally, but B cannot

Expected behavior
Expect normal interface documentation to be generated

@Cloverxue
Copy link
Author

url('^api-ui/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
url('^api-doc/', SpectacularRedocView.as_view(url_name='schema'), name='swagger-doc'),
The corresponding interface(versioning_class = NamespaceVersioning) cannot be found when opened using this two url

@tfranzel
Copy link
Owner

tfranzel commented Sep 7, 2023

https://drf-spectacular.readthedocs.io/en/latest/faq.html#i-get-an-empty-schema-or-endpoints-are-missing

you can do hardcode which version (as explained above) or give a parameter ...../api-ui/?version=v1

there is also the possibility for a dropdown in SwaggerUI: #1036 (comment)

@Cloverxue
Copy link
Author

Hi ,./manage.py spectacular --api-version 'YOUR_VERSION' can generate interface documents normally, but
url('^api-ui/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
url('^api-doc/', SpectacularRedocView.as_view(url_name='schema'), name='swagger-doc'),
The corresponding interface(versioning_class = NamespaceVersioning) cannot be found when opened using this two url

@Cloverxue
Copy link
Author

Ok, it's fine, thank you very much!

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