Sara Fuerst
Sara Fuerst

Reputation: 6068

Swagger Pattern not working with Swagger UI

I am making an API with swagger and am trying to update the YAML to add regex pattern requirements to the parameters. Currently I am trying the following:

# getCPIStatesForCountry endpoint
  /getCPIStatesForCountry:
    # This is a HTTP operation
    get:
      # Describe this verb here. Note: you can use markdown
      description: |
        Returns a list of states for a given country
      produces:
      - application/json
      # This is array of GET operation parameters:
      parameters:
        -
          name: country_code
          in: query
          description: Code of desired country
          required: true
          type: string
          pattern: "^[a-zA-Z]+$"

The Swagger UI, however, is letting me enter anything as valid input. Why is this?

Upvotes: 3

Views: 4808

Answers (1)

Helen
Helen

Reputation: 97540

Parameter validation against pattern is supported in Swagger UI 3.4.3 and later.

Upvotes: 3

Related Questions