Skip to content

Can you provide an example of using the swaggerUiBundleBasePath property? #73

@jelche

Description

@jelche

I need to be able to use the Swagger-UI and validation on a closed network and as such need to provide the static files. However when I follow what is in the READMe I get 404 responses. Here is how I've implemented the option:

const swaggerUiAssetPath = require("swagger-ui-dist").getAbsoluteFSPath();

const oasMw = await oas({
  file: `${__dirname}/../openapi.yaml`,
  swaggerUiBundleBasePath: swaggerUIAssetPath,
  endpoint: '/openapi.json',
  uiEndpoint: '/'
});


Is this the expected usage?

The only way I can seem to get it to work otherwise is to serve up the static files:

const serve = require('koa-static')
const swaggerUIAssetsPath = './node_modules/swagger-ui-dist'

app.use(serve(swaggerUIAssetsPath))

const oasMw = await oas({
  file: `${__dirname}/../openapi.yaml`,
  swaggerUiBundleBasePath: require(swaggerUIAssetsPath),
  endpoint: '/openapi.json',
  uiEndpoint: '/'
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions