Swagger UI does not show request parameter's validation information. I want to show parameter's min value, max value, format, pattern(regex). Does anyone know the way how I express the parameter's validation information on Swagger UI?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Assuming you use Swagger UI 3.x (the latest version), add showCommonExtensions: true
to the Swagger UI initialization code in your index.html
file:
const ui = SwaggerUIBundle({
"dom_id": "#swagger-ui",
url: "https://petstore.swagger.io/v2/swagger.json",
showExtensions: true, // <-----
...
Learn more about Swagger UI configuration parameters.
回答2:
By using openapi 3.0.0 I got a UI with validation information like that displayed in http://editor.swagger.io/. Conversion from openapi 2 to openapi 3 could be done at the following URL. https://mermade.org.uk/openapi-converter