설명
Swagger 2.0의 표준 필드는 해당 객체에서 사용하는 이름과 대소문자로 작성하세요. properties 안의 키는 API의 데이터 필드 이름입니다.
잠재적 영향
표준 필드의 철자가 틀리면 검증이 실패하거나 문서와 SDK에서 해당 설명이나 필드가 빠질 수 있습니다.
해결 방법
문서를 검증하고 생성된 파라미터 설명과 모델 필드를 확인하세요. 사용자 정의 메타데이터에는 해당 객체가 확장을 지원할 때 x- 접두사를 사용하세요.
예시
첫 번째 예시는 경로 파라미터의 description을 descripption으로 잘못 적었습니다.
변경 전
json
{
"swagger": "2.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/{id}": {
"get": {
"summary": "List API versions",
"responses": {
"200": {
"description": "OK"
}
},
"operationId": "listVersionsv2"
},
"parameters": [
{
"descripption": "ID of pet to use",
"required": true,
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "csv",
"name": "id",
"in": "path"
}
]
}
},
"definitions": {
"ErrorModel": {
"type": "object",
"required": [
"message",
"code"
],
"propppperties": {
"message": {
"type": "string"
},
"code": {
"type": "integer",
"minimum": 100,
"maximum": 600
}
}
}
}
}
변경 후
json
{
"swagger": "2.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/{id}": {
"get": {
"summary": "List API versions",
"responses": {
"200": {
"description": "OK"
}
},
"operationId": "listVersionsv2"
},
"parameters": [
{
"description": "ID of pet to use",
"required": true,
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "csv",
"name": "id",
"in": "path"
}
]
}
},
"definitions": {
"ErrorModel": {
"type": "object",
"required": [
"message",
"code"
],
"properties": {
"message": {
"type": "string"
},
"code": {
"type": "integer",
"minimum": 100,
"maximum": 600
}
}
}
}
}
ErrorModel의 propppperties도 properties로 고칩니다. 데이터 필드 message와 code는 그대로 유지합니다.