Skip to content

Commit da5b1d1

Browse files
author
PRITAM CHAKRABORTY
committed
swagger working v1
1 parent c241b73 commit da5b1d1

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

blogapp/views.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121

2222

2323
class BloggerViewSet(ModelViewSet):
24+
""" Blogger can retrive own details as well as others detail, but can only perform update,delete for own
25+
list:
26+
to get all bloggers
27+
"""
2428
http_method_names = ["get", "patch", "delete", "head", "options"]
2529
filter_backends = [
2630
DjangoFilterBackend,

core/settings/common.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
'django.contrib.messages',
3232
'django.contrib.staticfiles',
3333
# 3rd party apps
34+
# 'django.contrib.staticfiles', # required for serving swagger ui's css/js files
35+
'drf_yasg',
3436
# "debug_toolbar",
3537
'rest_framework',
3638
'djoser',

core/urls.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,44 @@
1313
1. Import the include() function: from django.urls import include, path
1414
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
1515
"""
16-
from django.conf import settings ,urls
16+
from django.conf import settings, urls
1717
from django.contrib import admin
1818
from django.urls import path, include
1919
from django.conf.urls.static import static
2020

21+
# DRF_YASG
22+
from rest_framework import permissions
23+
from drf_yasg.views import get_schema_view
24+
from drf_yasg import openapi
25+
26+
27+
schema_view = get_schema_view(
28+
openapi.Info(
29+
title="Blogapp API",
30+
default_version='v1',
31+
description="Test description",
32+
# terms_of_service="https://www.google.com/policies/terms/",
33+
# contact=openapi.Contact(email="pritam.chk98@gmail.com"),
34+
# license=openapi.License(name="BSD License"),
35+
),
36+
public=True,
37+
permission_classes=[permissions.AllowAny],
38+
)
39+
# DRF_YASG
40+
41+
2142
urlpatterns = [
2243
path('admin/', admin.site.urls),
2344
path('auth/', include('djoser.urls')),
2445
path('auth/', include('djoser.urls.jwt')),
2546
# path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
2647
# own app routes
2748
path('blogapp/', include("blogapp.urls")),
49+
#FIXME: drf_yasg url
50+
path('', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
2851
]
2952
# urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
3053

3154
if settings.DEBUG:
3255
import debug_toolbar
33-
urlpatterns+=path("__debug__/", include(debug_toolbar.urls)),
56+
urlpatterns += path("__debug__/", include(debug_toolbar.urls)),

db.sqlite3

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)