OpenAPI 미디어 타입 접두사 점검

본문 형식에 맞는 올바른 미디어 타입을 사용하세요.

설명

OpenAPI 3.0에서 요청·응답 본문의 content 키에는 실제 미디어 타입이나 지원하는 미디어 범위를 지정하세요.

잠재적 영향

오타가 있으면 생성된 클라이언트가 해당 본문 형식을 선택하지 못할 수 있습니다.

해결 방법

유효한 벤더 전용 타입과 미디어 범위는 유지하세요. 실제 Content-Type과 본문을 비교하고 재사용 응답은 작업에서 그 정의를 참조하는지 확인하세요.

예시

예시는 ResponseExample만 수정합니다. GET /의 200 응답은 별도로 정의되어 있습니다.

변경 전

json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0",
    "contact": {
      "name": "contact",
      "url": "https://www.google.com/",
      "email": "user@gmail.c"
    }
  },
  "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": {
    "responses": {
      "ResponseExample": {
        "description": "200 response",
        "content": {
          "applicasdsadtion/json": {
            "schema": {
              "properties": {
                "code": {
                  "type": "string",
                  "format": "binary"
                },
                "message": {
                  "type": "string"
                }
              },
              "type": "object"
            }
          }
        }
      }
    }
  }
}

변경 후

json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0",
    "contact": {
      "name": "contact",
      "url": "https://www.google.com/",
      "email": "user@gmail.c"
    }
  },
  "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": {
    "responses": {
      "ResponseExample": {
        "description": "200 response",
        "content": {
          "application/json": {
            "schema": {
              "properties": {
                "code": {
                  "type": "string",
                  "format": "binary"
                },
                "message": {
                  "type": "string"
                }
              },
              "type": "object"
            }
          }
        }
      }
    }
  }
}

applicasdsadtion/json을 application/json으로 고칩니다. JSON 응답에는 별도의 encoding 설정이 필요하지 않습니다.

참조