https://drf-yasg.readthedocs.io/en/stable/readme.html
pip install drf-yasg
settings.py:
INSTALLED_APPS = [
'django.contrib.staticfiles',
'drf_yasg',
]
urls.py:
...
from django.urls import path,include, re_path # re_path 추가
from rest_framework import permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
...
schema_view = get_schema_view(
openapi.Info(
title="Incheon Jumak", # 프로젝트 이름
default_version='v1', # 프로젝트 버전
description="Incheon Jumak test API 문서", # 해당 문서 설명
terms_of_service="https://www.google.com/policies/terms/",
contact=openapi.Contact(email="incheonjumak@gmail.com"), # 부가정보
license=openapi.License(name="A2_YUNIBUS"), # 부가정보
),
public=True,
permission_classes=[permissions.AllowAny],
)
urlpatterns = [
...
re_path(r'^swagger(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),
re_path(r'^swagger/$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
re_path(r'^redoc/$', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
...
]
https://django-rest-swagger.readthedocs.io/en/latest/settings/
https://drf-yasg.readthedocs.io/en/stable/custom_spec.html
'Django' 카테고리의 다른 글
django signal pre_save (2) | 2023.06.15 |
---|---|
drf filter __ 언더스코어 (4) | 2023.06.14 |
Django admin 페이지 커스텀하기 (1) | 2023.05.23 |
Django sqlite3 mysql로 변경하기 (11) | 2023.05.09 |
DRF BooleanField (2) | 2023.04.25 |