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

Missing swagger_fake_view attribute #321

Closed
d2718nis opened this issue Mar 1, 2021 · 2 comments
Closed

Missing swagger_fake_view attribute #321

d2718nis opened this issue Mar 1, 2021 · 2 comments
Labels
enhancement New feature or request fix confirmation pending issue has been fixed and confirmation from issue reporter is pending

Comments

@d2718nis
Copy link

d2718nis commented Mar 1, 2021

Hi. I'm using drf-spectacular with drf-nested-routers and faced an issue: whenever I'm raising Http404 inside get_queryset or before the method call, for example if the nested object does not exist, I get this warning when accessing Swagger schema view:

UserWarning: <ViewSet> not compatible with schema generation

I know that drf-yasg has a mechanism to distinguish a real view from the schema-generated one described in this issue axnsan12/drf-yasg#267:

if getattr(self, 'swagger_fake_view', False):
   return Offer.objects.none()

Unfortunately I wasn't able to find something like that for drf-spectacular. Maybe I'm missing something or this could be a feature request. Thanks!

@tfranzel tfranzel added the enhancement New feature or request label Mar 2, 2021
@tfranzel tfranzel added the fix confirmation pending issue has been fixed and confirmation from issue reporter is pending label Mar 2, 2021
@tfranzel
Copy link
Owner

tfranzel commented Mar 2, 2021

Hi! i was hesitant to do this before as it felt like a cop-out, but i realize now that sometimes you are simply stuck there and all other option are worse. i mean we do generate mock requests with an anon user, but apparently that is not enough the cover all cases.

so added the feature finally. 🚀

@d2718nis
Copy link
Author

d2718nis commented Mar 4, 2021

This is just wonderful, thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fix confirmation pending issue has been fixed and confirmation from issue reporter is pending
Projects
None yet
Development

No branches or pull requests

2 participants