我正在制作一个带有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让我输入任何有效输入。为什么是这样?
答案 0 :(得分:1)
Swagger UI 3.4.3及更高版本支持针对pattern
的参数验证。