Swagger 模式不适用于 Swagger UI

Swagger Pattern not working with Swagger UI

我正在大摇大摆地制作一个 API 并尝试更新 YAML 以将正则表达式模式要求添加到参数中。目前我正在尝试以下操作:

# 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]+$"

然而,Swagger UI 让我输入任何内容作为有效输入。为什么是这样?

Swagger UI 3.4.3 及更高版本支持针对 pattern 的参数验证。