2017-04-19 39 views
0

我正在使用swagger創建一個API,並試圖更新YAML以將正則表達式模式要求添加到參數中。目前我正在嘗試以下操作:Swagger模式不能與Swagger UI一起工作

# 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.0.6開始,Swagger UI不支持對pattern的輸入驗證。它只在模型屬性的描述中顯示pattern,但不用於原始參數。

您可以提交功能請求(或提供拉請求)on GitHub