Skip to content

options.htmlui no longer works for adding swagger docs #75

Open

Description

@dbevacqua

According to the docs, should be able to pass options like this to enable swagger:

const oapi = openapi({
  openapi: '3.0.0',
  info: {
    title: 'Express Application',
    description: 'Generated docs from an Express api',
    version: '1.0.0',
  }
}, { htmlui: 'swagger-ui' } )

// This will serve the generated json document(s)
// (as well as the swagger-ui if configured)
app.use(oapi)

This worked in v0.3.0 but does not work since v1.1.0. The problem seems to be that middleware.swaggerui was changed to a function but its call site was not updated:

git grep middleware.swaggerui v1.1.0 -- index.js
v1.1.0:index.js:  middleware.swaggerui = (options) => ui.serveSwaggerUI(`${routePrefix}.json`, options)
v1.1.0:index.js:      router.use(`${routePrefix}/swagger-ui`, middleware.swaggerui)
git grep middleware.swaggerui v0.3.0 -- index.js
v0.3.0:index.js:  middleware.swaggerui = ui.serveSwaggerUI(`${routePrefix}.json`, opts)
v0.3.0:index.js:      router.use(`${routePrefix}/swagger-ui`, middleware.swaggerui)

Activity

  1. added a commit that references this issue on Aug 12, 2025
    fe7d003
  2. Megapixel99 commented on Sep 22, 2025

    @Megapixel99
    Collaborator

    I do not believe you need to pass in the htmlui option... you should be able to use:

    const oapi = openapi({
      openapi: '3.0.0',
      info: {
        title: 'Express Application',
        description: 'Generated docs from an Express api',
        version: '1.0.0',
      }
    })
    
    ...
    
    app.use(oapi);
    
    ...
    
    app.get([
      '/',
      '/swagger-ui.css',
      '/swagger-ui-bundle.js',
      '/swagger-ui-standalone-preset.js',
      '/swagger-ui-init.js',
      openapi.routePrefix,
    ], oapi.swaggerui());
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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