이번에 swagger 파일을 만드는 작업은 FastAPI 에서 http://localhost:8000/openapi.json url 을 통해 얻을 수 있는
swagger 파일은 3.1.0 인데, 3.0.0 버전의 파일이 필요해서 진행하게 되었습니다.
더보기
더보기
{
"openapi": "3.1.0",
"info": {
"title": "FastAPI",
"version": "0.1.0"
},
"paths": {
"/v1/chat/completions": {
"post": {
"summary": "Chat Completions",
"operationId": "chat_completions_v1_chat_completions_post",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
}
}
}
}
}
}
},
"/health": {
"get": {
"summary": "Health",
"operationId": "health_health_get",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
}
}
}
}
}
}
}
}
}
[pip 설치]
pip install openapi-downgrade
pip install --upgrade prance openapi-spec-validator click
[swagger 3.1 → 3.0]
openapi_downgrade http://localhost:8000/openapi.json openapi_v3.json
[검증]
prance validate openapi_v3.json
-- Processing "openapi_v3.json"...
-- -> Resolving external references.
-- Validates OK as OpenAPI 3.0.3!