Skip to content

Commit

Permalink
feat: setup swagger docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chandansgowda committed Aug 20, 2023
1 parent a4a8672 commit a64b197
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'drf_spectacular',
'core',
]

Expand Down Expand Up @@ -129,3 +131,7 @@
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

AUTH_USER_MODEL = 'core.User'

REST_FRAMEWORK = {
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
}
8 changes: 8 additions & 0 deletions app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from drf_spectacular.views import (
SpectacularAPIView,
SpectacularSwaggerView,
)

from django.contrib import admin
from django.urls import path

urlpatterns = [
path('admin/', admin.site.urls),
path('api/schema/', SpectacularAPIView.as_view(), name='api-schema'),
path('api/docs/', SpectacularSwaggerView.as_view(url_name='api-schema'),
name='api-docs',)
]
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Django>=3.2.4,<3.3
djangorestframework>=3.12.4,<3.13
psycopg2>=2.8.6,<2.9
psycopg2>=2.8.6,<2.9
drf-spectacular>=0.15.1,<0.16

0 comments on commit a64b197

Please sign in to comment.