2016-02-16 28 views
1

我在Swagger API文檔/列表頁面上出現錯誤。所有的電話正常工作,只是圖像細節錯誤是不舒服的樣子。當我鑽入錯誤時,我收到以下json響應:Swagger在API UI屏幕上顯示錯誤部分

{"schemaValidationMessages":[{"level":"error","domain":"validation","keyword":"minItems","message":"array is too short: must have at least 1 elements but instance has 0 elements","schema":{"loadingURI":"http://json-schema.org/draft-04/schema#","pointer":"/properties/enum"},"instance":{"pointer":"/definitions/Permissions/properties/permissionType/enum"}}]} 

有沒有人遇到過這個問題? Error on API pager.

回答

4

Swagger將始終驗證您的模式對他們的在線驗證器。在你的情況下,它的驗證失敗,因爲permissionType枚舉沒有元素,按照返回的JSON。如果您確實想要解決問題並不可行,那麼您可以使用Swagger的validatorUrl參數來關閉驗證 - 請參閱this link。如果您想通過Swashbuckle要做到這一點,你可以使用:

.EnableSwaggerUi(c => 
{ 
     // Your other config... 
     c.DisableValidator(); 
}); 

爲每Swashbuckle documentation