As per swagger documentation,
Swagger-UI accepts configuration parameters in four locations.
From lowest to highest precedence:
- The swagger-config.yaml in the project root directory, if it exists, is baked into the application
- configuration object passed as an argument to Swagger-UI (SwaggerUI({ ... }))
- configuration document fetched from a specified configUrl
- configuration items passed as key/value pairs in the URL query string
I have tried to put swagger-config.yaml in root pat of application but its not working.
I have followed swagger Installation steps and its working correct. but steps for swagger custom config is not working. I have kept files as below,
swagger-ui
|--swagger-config.yaml
|--index.html
url: "https://petstore.swagger.io/v2/swagger.json"
dom_id: "#swagger-ui"
validatorUrl: "https://online.swagger.io/validator"
oauth2RedirectUrl: "http://localhost:3200/oauth2-redirect.html"
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
//url: "https://petstore.swagger.io/v2/swagger.json",
//dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
Any idea if I am missing anything ?
Simply drag and drop your OpenAPI JSON or YAML document into the Swagger Editor browser window. File → Import URL. Paste the URL to your OpenAPI document.
The swagger-config. yaml in the project root directory, if it exists, is baked into the application. configuration object passed as an argument to Swagger-UI (SwaggerUI({ ... })) configuration document fetched from a specified configUrl.
By default, Swagger UI uses BaseLayout , which is built into the application. You can specify a different layout to be used by passing the layout's name as the layout parameter to Swagger UI. Be sure to provide your custom layout as a component to Swagger UI.
Swagger definitions can be written in JSON or YAML. In this guide, we only use YAML examples, but JSON works equally well. A sample Swagger specification written in YAML looks like: swagger: "2.0"
I also have this issue. From the document, it seems we don't need to config anything in index.html if use swagger-config.xml, actually, it doesn't work from my side, I have not find the reason. But if use configUrl instead, it works.
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
//url: "https://petstore.swagger.io/v2/swagger.json",
//dom_id: '#swagger-ui',
configUrl: "../swagger-config.yaml",
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
And it can be configured to support the array.
---
urls:
- url: "https://petstore.swagger.io/v2/swagger.json"
name: "url1"
- url: "https://petstore.swagger.io/v2/swagger.json"
name: "url2"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With