diff --git a/backend/core/settings.py b/backend/core/settings.py index 84cd4c5..5c01d05 100644 --- a/backend/core/settings.py +++ b/backend/core/settings.py @@ -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': 'TurTask API', + 'DESCRIPTION': 'API documentation for TurTask', + 'VERSION': '1.0.0', + 'SERVE_INCLUDE_SCHEMA': False, } REST_USE_JWT = True diff --git a/backend/core/urls.py b/backend/core/urls.py index 418903f..a02869c 100644 --- a/backend/core/urls.py +++ b/backend/core/urls.py @@ -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'), ] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 2f9a5c4..98f2a15 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 \ No newline at end of file +Pillow>=10.1 +drf-spectacular>=0.26 \ No newline at end of file