Merge pull request #24 from TurTaskProject/feature/swagger-openapi

Add Swagger Doc
This commit is contained in:
Sirin Puenggun 2023-11-05 22:34:45 +07:00 committed by GitHub
commit e123751f35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 2 deletions

View File

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

View File

@ -16,6 +16,7 @@ Including another URLconf
""" """
from django.contrib import admin from django.contrib import admin
from django.urls import path, include from django.urls import path, include
from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
@ -23,4 +24,7 @@ urlpatterns = [
path('api/', include('tasks.urls')), path('api/', include('tasks.urls')),
path('api/', include('authentications.urls')), path('api/', include('authentications.urls')),
path('accounts/', include('allauth.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_oauthlib>=1.1
google-auth-httplib2>=0.1 google-auth-httplib2>=0.1
django-storages[s3]>=1.14 django-storages[s3]>=1.14
Pillow>=10.1 Pillow>=10.1
drf-spectacular>=0.26