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.

Paige
gefragt vor einem Monat286 Aufrufe
2 Antworten
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
EXPERTE
beantwortet vor einem Monat
profile picture
EXPERTE
überprüft vor einem Monat
0

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

Paige
beantwortet vor einem Monat
  • Does my answer solve your question or do I misunderstand your issue?

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen