-
-
Notifications
You must be signed in to change notification settings - Fork 181
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
feat(backend): generate OpenAPI v3 swagger docs #5259
base: main
Are you sure you want to change the base?
Conversation
4e2fe1e
to
be3c033
Compare
@@ -58,7 +58,7 @@ def filter_renderers(self, renderers, format): | |||
|
|||
class MediaFileRenderer(BaseRenderer): | |||
media_type = '*/*' | |||
format = None | |||
format = 'TODO' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drf_spectacular
requires format
to be a string, otherwise it crashes. What would the right format here?
@@ -24,7 +24,7 @@ class AssetJsonRenderer(renderers.JSONRenderer): | |||
|
|||
class MediaFileRenderer(renderers.BaseRenderer): | |||
media_type = '*/*' | |||
format = None | |||
format = 'TODO' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drf_spectacular
requires format
to be a string, otherwise it crashes. What would the right format here?
path('api/schema/', SpectacularAPIView.as_view(), name='schema'), | ||
path( | ||
'api/schema/swagger/', | ||
SpectacularSwaggerView.as_view(url_name='schema'), | ||
name='swagger-ui', | ||
), | ||
path( | ||
'api/schema/redoc/', | ||
SpectacularRedocView.as_view(url_name='schema'), | ||
name='redoc', | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copied the example from docs for a quick PoC. Questions:
- what api path you'd like?
- is this the right
urls.py
to add spectacular to urls? - let's use swagger or redoc, or both? My preference is swagger.
6f27d32
to
c242689
Compare
c242689
to
eec41c2
Compare
🗒️ Checklist
<type>(<scope>)<!>: <title> TASK-1234
frontend
orbackend
unless it's global📣 Summary
Automatically generate and display API schema.
📖 Description
Automatically generate OpenAPI v3 schema and display it in both swagger and redoc. See urls:
👀 Preview steps
💭 Notes
The schema most likely is not complete nor accurate. The scope of this PR is auto-generate schema as-is as a starting point, to enable iteration and improvement of the schema over time.
The purpose of auto-generated schema is twofold:
I considered three options for schema generation:
Reviewers, please help me to pack this properly for merging, this PR is rough like a quick PoC.
Screenshots of swagger and redoc: