Add Swagger Doc

This commit is contained in:
sosokker 2023-11-05 22:15:25 +07:00
parent eb22d30a24
commit b07179f121
3 changed files with 16 additions and 2 deletions

View File

@ -54,6 +54,7 @@ INSTALLED_APPS = [
'authentications',
'corsheaders',
'drf_spectacular',
'allauth',
'allauth.account',
@ -76,7 +77,15 @@ REST_FRAMEWORK = {
'rest_framework.authentication.TokenAuthentication',
'rest_framework_simplejwt.authentication.JWTAuthentication',
'dj_rest_auth.jwt_auth.JWTCookieAuthentication',
]
],
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
}
SPECTACULAR_SETTINGS = {
'TITLE': 'Your Project API',
'DESCRIPTION': 'Your project description',
'VERSION': '1.0.0',
'SERVE_INCLUDE_SCHEMA': False,
}
REST_USE_JWT = True

View File

@ -16,6 +16,7 @@ Including another URLconf
"""
from django.contrib import admin
from django.urls import path, include
from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView
urlpatterns = [
path('admin/', admin.site.urls),
@ -23,4 +24,7 @@ urlpatterns = [
path('api/', include('tasks.urls')),
path('api/', include('authentications.urls')),
path('accounts/', include('allauth.urls')),
path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
path('api/schema/swagger-ui/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
path('api/schema/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'),
]

View File

@ -13,4 +13,5 @@ google_api_python_client>=2.1
google_auth_oauthlib>=1.1
google-auth-httplib2>=0.1
django-storages[s3]>=1.14
Pillow>=10.1
Pillow>=10.1
drf-spectacular>=0.26