Django Rest Framework API document를 자동으로 생성해주는 Package
settings/drfy.py
#restframework + swagger
import os
from django.conf.urls import url
from django.urls import path, include
from drf_yasg.views import get_schema_view
from rest_framework.permissions import AllowAny, IsAuthenticated, BasePermission
from drf_yasg import openapi
schema_url_patterns=[
path('api/', include('api.urls'))
]
# schema_url_patterns = [
# path('')
# ]
schema_view = get_schema_view(
openapi.Info(
title="PLAPLZ REST API DOCS",
default_version="v1_210930",
description="플레이플리즈 홈페이지 RESTAPI 도큐먼트",
terms_of_service="https://www.django-rest-framework.org/topics/documenting-your-api/",
contact=openapi.Contact(name="개발매니저 이상학", email="eaa0305@naver.com"),
license=openapi.License(name="Beyondimension.inc"),
),
validators=['flex'],
public=True,
permission_classes=(AllowAny,),
patterns=schema_url_patterns,
)
settings/urls.py
from .drfy import *
urlpatterns = [
path('api/', include('api.urls')),
path('admin/', admin.site.urls),
path('accounts/', include('allauth.urls')),
path('', include('core.urls', namespace='core')),
path('invitation/', include('invitations.urls', namespace='invitations')),
path('swagger<str:format>', schema_view.without_ui(cache_timeout=0), name='schema-json'),
path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
path('docs/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
]