FE์ BE์ ์ํํ ์ํต์ ํตํด ์ฝ๋์ ์ ์ง, ๋ณด์, ๊ฐ๋ฐ ์๋๋ฅผ ๋ชจ๋ ํฅ์์ํฌ ์ ์๋ ๋ฐฉ๋ฒ์ด๋ค.
Postman, dbeaver๋ฅผ ์ง์ ์ผ์ ์ฌ์ฉํ๋ ๊ฒ๋ณด๋ค ๋ ๋ซ๋ค.
base.py์ SWAGGER_SETTINGS ์ถ๊ฐ
JWT ํ ํฐ์ผ๋ก authorization์ ๋ถ์ฌํ์๋ค.
SWAGGER_SETTINGS = {
'USE_SESSION_AUTH': False,
'SECURITY_DEFINITIONS': {
'BearerAuth': {
'type': 'apiKey',
'name': 'Authorization',
'in': 'header',
'description': "JWT Token"
}
},
'SECURITY_REQUIREMENTS': [{
'BearerAuth': []
}]
}
swagger url์ ulrpatterns์ ์ถ๊ฐํด์ค๋ค.
schema_view๋ฅผ ํ์ฉํด customํ๊ฒ ํ์ด์ง ์ฒซ ํ๋ฉด์ ์ค์ ํ ์ ์๋ค.
redoc์ ๋ค๋ฅธ UI๋ฅผ ๋ณด์ธ๋ค.
๐ฆด
- requirements.txt ์ drf-yasg==1.21.7 ์ถ๊ฐ๋ฅผ ์์ง๋ง์!
- pip install --upgrade setuptools
- base.py INSTALLED_APPS ์ 'drf-yasg' ์ถ๊ฐํด์ผ๋ง swagger templates์ ๊ฐ์ ธ์ฌ ์ ์๋ค.
schema_view = get_schema_view(
openapi.Info(
title="Lambda Genesis Api",
default_version='Version : 1.0.0',
description="Lambda Genesis Api ๋ฌธ์)",
terms_of_service="~",
contact=openapi.Contact(email="~"), # ๋ถ๊ฐ์ ๋ณด
license=openapi.License(name="Lambda"), # ๋ถ๊ฐ์ ๋ณด
),
public=True,
permission_classes=[permissions.AllowAny],
)
urlpatterns = [
path(r'swagger(?P<format>\.json|\.yaml)/', schema_view.without_ui(cache_timeout=0), name='schema-json'),
path(r'swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
path(r'redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc-v1'),

http://127.0.0.1:8000/swagger/
๐JWT Token Receive
โผ๏ธJWTโ โToken // ํ์์ผ๋ก ์ ๋ ฅํด์ผํฉ๋๋ค.


deployment.yaml ์์ ์์ ๊ฐ์ด django์์ ์คํํ๊ฒ๋ ํ์ฌ dev ์น์์ ์ฌ์ฉ์ด ๊ฐ๋ฅํ๊ฒ๋ ๋ฐ๊ฟ์ฃผ์๋ค.(eks ์ฌ์ฉ)
ํ๋ฒ์ ์ ์ฉ์ด ์๋๋ ๊ฒ์ ๋ณด๊ณ rancher๋ฅผ ํ์ธํ์ฌ image๊ฐ ์
๋ฐ์ดํธ๊ฐ ์๋ ๊ฒ์ ํ์ธํ์๋ค. argocd์์ sync๋ฅผ ์ฌ์ฉํด update ํ ์ ์ํ์๋๋ ์ ์์ ์ผ๋ก ์ ์์ด ๋์๋ค.

urls.py์์ if ๋ฌธ์ผ๋ก ๋๋ฒ๊น ๋ชจ๋๋ก ๋ค์ด๊ฐ๋๋ง swagger ๋ณผ ์ ์๊ฒ๋ ํด์ค์ผํจ. (์ฆ, dev mode์ผ ๋๋ง ๊ฐ๋ฅํ๋๋ก ํด์ค์ผํจ.)
question, add student ๊ฐ์ ์์ ์ input ์ด requiredํจ์ผ๋ก ์์ ์ด ํ์ํ๋ค.