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

Swagger UI endpoint is broken #471

Closed
2 tasks done
to-sta opened this issue Oct 17, 2023 · 3 comments
Closed
2 tasks done

Swagger UI endpoint is broken #471

to-sta opened this issue Oct 17, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@to-sta
Copy link
Collaborator

to-sta commented Oct 17, 2023

Terms

Behavior

While working on #450 I discovered that the /v1/schema/swagger-ui/ does not work anymore. I went thru the commit history to find out what cause the issue and figured out that its caused by:

import django_stubs_ex
django_stubs_ext.monkeypatch(extra_classes=(viewsets.ModelViewSet,))

It somehow override the DEFAULT_SCHEMA_CLASS that we are setting in the REST_FRAMEWORK dictionary.

>>> from rest_framework.settings import api_settings
>>> api_settings.DEFAULT_SCHEMA_CLASS
<class 'rest_framework.schemas.openapi.AutoSchema'>

When I remove django_stubs_ex, than we are getting the right result.

>>> from rest_framework.settings import api_settings
>>> api_settings.DEFAULT_SCHEMA_CLASS
<class 'drf_spectacular.openapi.AutoSchema'>

I found a open issue on djang-stubs with the same problem. Any ideas on how we could solve that?

We could wait and see if the issue gets resolved or in case we need SwaggerUI soon, we could adjust mypy. We could change the settings on generics and remove the monekypatch().

We could also discover issues like this with testing our endpoints. The page currently returns a HTTP 500 status code.

django_backend  | [17/Oct/2023 20:52:22] "GET /v1/schema/ HTTP/1.1" 500 108779
@to-sta to-sta added the bug Something isn't working label Oct 17, 2023
@to-sta
Copy link
Collaborator Author

to-sta commented Oct 18, 2023

I found a solution and will make PR right away. Let's keep the issue open till this djangorestframework-stubs issue gets resolved.

@andrewtavis
Copy link
Member

Makes sense to leave this open, @to-sta :) PR is merged and we can keep an eye on this 🙃

@andrewtavis andrewtavis moved this from Todo to In Progress in activist Board Nov 15, 2023
@andrewtavis
Copy link
Member

Closing based on a discussion with @to-sta 🥳

@github-project-automation github-project-automation bot moved this from In Progress to Done in activist Board Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

2 participants