feat(api): Add drf-spectacular
This commit is contained in:
parent
d2270b7866
commit
eecfdc8c1d
3 changed files with 23 additions and 1 deletions
|
@ -75,6 +75,7 @@ in
|
|||
ps.django-stubs
|
||||
ps.django-unfold
|
||||
ps.djangorestframework
|
||||
ps.drf-spectacular
|
||||
ps.ipython
|
||||
ps.loadcredential
|
||||
ps.pykanidm
|
||||
|
@ -85,6 +86,7 @@ in
|
|||
]
|
||||
++ ps.django-allauth.optional-dependencies.saml
|
||||
++ ps.django-allauth.optional-dependencies.socialaccount
|
||||
++ ps.drf-spectacular.optional-dependencies.sidecar
|
||||
))
|
||||
] ++ check.enabledPackages;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from django.urls import path
|
||||
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView
|
||||
|
||||
from . import views
|
||||
|
||||
|
@ -6,4 +7,11 @@ app_name = "api"
|
|||
|
||||
urlpatterns = [
|
||||
path("user/<str:username>/", views.UserView.as_view()),
|
||||
# Schema views
|
||||
path("schema/", SpectacularAPIView.as_view(), name="schema"),
|
||||
path(
|
||||
"schema/swagger-ui/",
|
||||
SpectacularSwaggerView.as_view(url_name="api:schema"),
|
||||
name="swagger-ui",
|
||||
),
|
||||
]
|
||||
|
|
|
@ -57,6 +57,8 @@ INSTALLED_APPS = [
|
|||
# API
|
||||
"rest_framework",
|
||||
"api",
|
||||
"drf_spectacular",
|
||||
"drf_spectacular_sidecar",
|
||||
]
|
||||
|
||||
###
|
||||
|
@ -258,7 +260,17 @@ VLAN_AUTOCONNECT = credentials.get("VLAN_AUTOCONNECT", False)
|
|||
REST_FRAMEWORK = {
|
||||
"DEFAULT_AUTHENTICATION_CLASSES": [
|
||||
"api.authentication.TokenAuthentication",
|
||||
]
|
||||
],
|
||||
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
|
||||
}
|
||||
|
||||
|
||||
SPECTACULAR_SETTINGS = {
|
||||
"TITLE": "DG·SI API",
|
||||
"VERSION": "0.1.0",
|
||||
"SWAGGER_UI_DIST": "SIDECAR", # shorthand to use the sidecar instead
|
||||
"SWAGGER_UI_FAVICON_HREF": "SIDECAR",
|
||||
"REDOC_DIST": "SIDECAR",
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue