Show Swagger validation information

蹲街弑〆低调 提交于 2019-12-20 05:32:07

问题


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



来源:https://stackoverflow.com/questions/53580982/show-swagger-validation-information

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!