説明
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 に変え、許可された文字だけを使用しています。参照がある場合は、新しい名前と完全に一致するように更新してください。