How to hide the Models section in Swagger UI?

To hide the “Models” section, add defaultModelsExpandDepth: -1 to the Swagger UI configuration code in your index.html. Note the option name uses plural Model*s* not Model. // index.html <script> window.onload = function() { // Begin Swagger UI call region const ui = SwaggerUIBundle({ url: “https://petstore.swagger.io/v2/swagger.json”, dom_id: ‘#swagger-ui’, defaultModelsExpandDepth: -1, // <——- Swagger UI also has … Read more

Swagger UI with Multiple Urls

The urls configuration option is supported in Swagger UI 3.0.18 and later. You can use it instead of url like this: window.onload = function() { // Build a system const ui = SwaggerUIBundle({ urls: [ {url: “https://path/to/api1.yaml”, name: “API One”}, {url: “https://path/to/api2.yaml”, name: “API Two”}, ], “urls.primaryName”: “API Two” // default document (if other than … Read more

How to embed Swagger UI into a webpage?

The answer depends on whether you have a plain web page you edit directly, or use a framework like Node.js or React. For simplicity, I’ll assume the former. Download (or clone) the Swagger UI repository. You’ll need the following files from the dist folder: swagger-ui.css swagger-ui-bundle.js swagger-ui-standalone-preset.js In the <head> section of your web page, … Read more