Can you have multiple dynamic paths in API Gateway, defined by an OpenAPI spec?

1

I have an open API 3.0 spec that I am trying to upload into API Gateway. I have two paths that are both dynamic, but one has more variables than the other. For example:

paths:
  /{a_path}
    get:
     ...
  /{b_path}/{x}/{y}/{z} 
    get:
      ...

When I try to import my spec into API Gateway I get the following error,

Unable to create resource at path '/{b_path}/{x}/{y}/{z}': A sibling ({a_path}) of this resource already has a variable path part -- only one is allowed

Is this allowed? Any recommendation on how to change my spec to allow for these multiple dynamic paths? This pattern has worked on GCP, so I am assuming that this is not an Open API restriction.

2개 답변
1

Hi,

Yes, It is possible to have multiple dynamic paths, as long as the path variables are the same. I assume that the API Gateway will validate the route path by path, and there can be no ambiguities.

{
  "openapi" : "3.0.1",
  "info" : {
    "title" : "Test",
  },
  "paths" : {
    "/{a}" : {
      "get" : {
        "parameters" : [ {
          "name" : "a",
          "in" : "path",
          "required" : true,
          "schema" : {
            "type" : "string"
          }
        } ],
        "responses" : {
          "200" : {
            "description" : "200 response",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/Empty"
                }
              }
            }
          }
        }
      }
    },

    "/{a}/{b}" : {
      "get" : {
        "parameters" : [ {
          "name" : "a",
          "in" : "path",
          "required" : true,
          "schema" : {
            "type" : "string"
          }
        }, {
          "name" : "b",
          "in" : "path",
          "required" : true,
          "schema" : {
            "type" : "string"
          }
        } ],
        "responses" : {
          "200" : {
            "description" : "200 response",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/Empty"
                }
              }
            }
          }
        }
      }
    },
  },
  "components" : {
    "schemas" : {
      "Empty" : {
        "title" : "Empty Schema",
        "type" : "object"
      }
    }
  }
}

profile picture
전문가
답변함 한 달 전
profile picture
전문가
검토됨 한 달 전
0

The non-matching path variables was my issue, thank you for the response!

Paige
답변함 한 달 전
  • Does my answer solve your question or do I misunderstand your issue?

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠