3

I imported an OpenAPI definition json into AWS API Gateway, and I noticed that none of path or query parameter validations works. I am hoping to do /card/{type}?userId={userId}, where type belongs to a set of enum values and userId with a regex pattern, as follows:

"paths: {
  "/card/{type}": {
    "get": {
      "operationId": "..",
      "parameters": [
        {
           "name": "type",
           "in": "path",
           "schema": {"$ref": "#/components/schemas/type}
        },
        {
           "name": "userId"
           "in": "query",
           "schema": {
             "type": "string",
             "pattern": "<some regex>"
           }
        },
        ...
      ]
    }
  }
}

Turns out I can input whatever values I want for both path and query parameters. So I try exporting the OpenAPI file from AWS Console, and I got:

   ...
      "parameters": [
        {
           "name": "type",
           "in": "path",
           "schema": {
             "type": "string"
           }
        },
        {
           "name": "userId"
           "in": "query",
           "schema": {
             "type": "string"
        }

For API Gateway, are the validators not working for what's part of URL? because the requests with body seem to work fine. Or is there something I am missing?

夢のの夢
  • 5,054
  • 7
  • 33
  • 63
  • AWS does not support regex validation. https://stackoverflow.com/questions/47849438/aws-api-gateway-query-parameter-validation – madeeha Feb 09 '22 at 18:51

0 Answers0