I followed instructions to set up swagger documentation for my existing node API using swagger-jsdoc. The swagger.json is being served correctly and I added a path to it in the url parameter of the SwaggerUiBundle in index.html like this:
const ui = SwaggerUIBundle({
url: "https://my.domain:5292/swagger.json",
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout" })
However, the first thing it tries to do when opening the page in the browser is showing the default http://petstore.swagger.io/v2/swagger.json instead of my swagger.json. It actually fails to do so because I'm serving the page through https and the petstore is not https but that's a different matter...
Inputing my address to the swagger.json manually into the form on the page works as expected. It shows the API page correctly and validates it. However, I don't want to always re-enter the address there and would like to have it as a default.
This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger.
Swagger will automatically generate a swagger. json file for us at the endpoint localhost:8080/v2/api-docs which includes information about our APIs.
Swagger Editor: Swagger Editor lets you edit OpenAPI specifications in YAML inside your browser and to preview documentations in real time. Swagger UI: Swagger UI is a collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from an OAS-compliant API.
Swagger definitions can be written in JSON or YAML. In this guide, we only use YAML examples, but JSON works equally well.
Swagger UI 3.0.9 had a bug where it ignored the url
parameter and always opened Petstore.
It was fixed in 3.0.10.
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