Swagger模式与Swagger UI不兼容

3

我正在使用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个回答

3

Swagger UI 3.4.3及以上版本支持对pattern进行参数验证。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接