Swagger模式不适用于Swagger UI

时间:2017-04-19 14:19:53

标签: swagger swagger-ui swagger-2.0 swagger-editor

我正在制作一个带有swagger的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让我输入任何有效输入。为什么是这样?

1 个答案:

答案 0 :(得分:1)

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