Skip to content

Failed to load spec. when trying to get swagger.json. #3157

@martinpagesaal

Description

@martinpagesaal

Hi,

I'm new in swagger. I'm trying to set some jwt security on swagger.json file, so it cant be access on stage env by all users.

I'm using an express server btw.

app.get('/swagger.json', jwt(), function(req, res) {
    res.setHeader('Content-Type', 'application/json');
    res.send(swaggerSpec);
  });

and in my api-docs/index.html I have

window.onload = function() {

  // Build a system
  const ui = SwaggerUIBundle({
    url: "/swagger.json",
    dom_id: '#swagger-ui',
    presets: [
      SwaggerUIBundle.presets.apis,
      SwaggerUIStandalonePreset
    ],
    plugins: [
      SwaggerUIBundle.plugins.DownloadUrl
    ],
    layout: "StandaloneLayout"
  })

  window.ui = ui
}

I end up with "Failed to load spec." error. (it works perfectly when I remove jwt()

I'm using. Swagger-JS 3.0.12

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions