파라미터 위치에 맞지 않는 allowReserved 설정

파라미터의 allowReserved는 query 위치에서만 사용하세요.

설명

OpenAPI 3.0의 Parameter Object에서 allowReserved는 쿼리 값에만 적용됩니다. 경로, 헤더, 쿠키 매개변수에는 효과가 없습니다.

잠재적 영향

경로 값에 포함된 슬래시가 다음 경로 구간의 시작으로 해석될 수 있습니다.

해결 방법

쿼리 이외의 매개변수에서는 allowReserved를 제거하고 매개변수 위치는 유지하세요. 스키마가 예약 문자를 포함한 값을 허용할 때만 해당 문자의 인코딩을 테스트하세요.

예시

두 경로의 id 매개변수를 보여 줍니다. /users/{id}의 응답 정의는 생략했습니다.

변경 전

json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Simple API overview",
    "version": "1.0.0"
  },
  "paths": {
    "/{id}": {
      "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"
                            }
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "description": "ID of the API the version",
          "required": true,
          "allowReserved": true,
          "schema": {
            "type": "integer"
          }
        }
      ]
    },
    "/users/{id}": {
      "get": {
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "allowReserved": true,
            "description": "The user ID",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ]
      }
    }
  }
}

변경 후

json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Simple API overview",
    "version": "1.0.0"
  },
  "paths": {
    "/{id}": {
      "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"
                            }
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "description": "ID of the API the version",
          "required": true,
            "schema": {
            "type": "integer"
          }
        }
      ]
    },
    "/users/{id}": {
      "get": {
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
                "description": "The user ID",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ]
      }
    }
  }
}

두 경로 모두 정수 id가 필수입니다. 각 경로에 정수를 넣어 테스트하세요.

참조