drf-spectacular
swagger
β μ€μ¨κ±°(swagger)λ κ°λ°μκ° REST μΉ μλΉμ€λ₯Ό μ€κ³, λΉλ, λ¬Έμν, μλΉνλ μΌμ λμμ£Όλ μ€ν μμ€ μννΈμ¨μ΄ νλ μμν¬
β μ¦, APIλ₯Ό μ€κ³νκ³ λ¬Έμν νλλ° λμμ μ£Όλ λΌμ΄λΈλ¬λ¦¬
λ€μν DRF API
β μ€μ¨κ±°(swagger)λ₯Ό μμ±ν μ μλλ‘ λμμ μ£Όλ λΌμ΄λΈλ¬λ¦¬ -> drf-spectacular
drf-spectacular
β Open API 3.0μ μ§μνλ DRF API OpenAPI μμ±κΈ°
- μ€μΉ λ° λ±λ‘
$ pip install drf-spectacular
$ pip freeze > requirements.txt
# my_api/settings.py
INSTALLED_APPS = [
'drf_spectacular'
]
- κΈ°λ³Έ μ€μ
# my_api/settings.py
REST_FRAMEWORK = {
...
# spectacular Settings
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
}
SPECTACULAR_SETTINGS = {
'TITLE': 'Your Project API',
'DESCRIPTION': 'Your project description',
'VERSION': '1.0.0',
'SERVE_INCLUDE_SCHEMA': False,
# OTHER SETTINGS
}
- URL μ€μ
# articles/urls.py
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView
...
urlpatterns = [
...
# νμ μμ±
path('schema/', SpectacularAPIView.as_view(), name='schema'),
# optional UI
path('swagger/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
]
- κ²°κ³Ό νμΈ
![](https://blog.kakaocdn.net/dn/k54ko/btrRcPUATOm/pKzxQIK5Ped73zypFsoB60/img.png)
'β Personal_Study > Vue' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
DRF Auth with Vue (0) | 2022.11.23 |
---|---|
DFR Auth System (0) | 2022.11.22 |
Vue with DRF (0) | 2022.11.21 |
Cross - Origin Resource Sharing (CORS) (0) | 2022.11.20 |
Vue with DRF: Server & Client (0) | 2022.11.20 |
λκΈ