설명
OpenAPI 3.0의 components.schemas, responses, parameters 등에 정의하는 컴포넌트 이름에는 공백이나 허용되지 않은 특수 문자를 넣을 수 없습니다. 이름은 하나 이상의 영문자, 숫자, 점(.), 하이픈(-), 밑줄(_)로 구성해야 합니다.
잠재적 영향
- 문서 검증에 실패하거나 도구가 컴포넌트 이름을 다르게 처리할 수 있습니다.
- 이름을 일관되게 해석하지 못하면 참조 해석이나 코드 생성에 문제가 생길 수 있습니다.
해결 방법
컴포넌트 이름에서 공백과 허용되지 않은 문자를 제거하세요. 이름을 바꿀 때 해당 컴포넌트를 가리키는 모든 $ref도 수정하고, 외부 문서의 참조를 함께 확인하세요. 수정 후 이름과 참조 경로를 검증하세요.
예시
다음은 컴포넌트 이름의 공백을 제거하는 비교입니다.
변경 전
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response",
"content": {
"application/json": {
"examples": {
"foo": {
"value": {
"versions": [
{
"status": "CURRENT",
"updated": "2011-01-21T11:33:21Z",
"id": "v2.0",
"links": [
{
"href": "http://127.0.0.1:8774/v2/",
"rel": "self"
}
]
}
]
}
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"General Error": {
"type": "object",
"discriminator": {
"propertyName": "petType"
},
"properties": {
"code": {
"type": "string",
"format": "int32"
},
"message": {
"type": "string"
}
},
"required": [
"petType"
]
}
}
}
}
변경 후
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response",
"content": {
"application/json": {
"examples": {
"foo": {
"value": {
"versions": [
{
"status": "CURRENT",
"updated": "2011-01-21T11:33:21Z",
"id": "v2.0",
"links": [
{
"href": "http://127.0.0.1:8774/v2/",
"rel": "self"
}
]
}
]
}
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"GeneralError": {
"type": "object",
"discriminator": {
"propertyName": "petType"
},
"properties": {
"code": {
"type": "string",
"format": "int32"
},
"message": {
"type": "string"
}
},
"required": [
"petType"
]
}
}
}
}
General Error를 GeneralError로 바꿔 허용된 문자만 사용합니다. 참조가 있는 경우 새 이름과 정확히 일치하도록 갱신해야 합니다.