express-openapi icon indicating copy to clipboard operation
express-openapi copied to clipboard

Cannot Use Multiple OpenAPI Middlewares

Open henry232323 opened this issue 2 months ago • 0 comments

There is no way to generate two separate OpenAPI specs for the app. For example:

const document1: OpenAPIV3.Document = {
  openapi: "3.1.0",
  info: {},
  paths: {},
  components: {
    schemas: {},
  },
  servers: [],
}

const document2: OpenAPIV3.Document = {
  openapi: "3.1.0",
  info: {},
  paths: {},
  components: {
    schemas: {},
  },
  servers: [],
}

export const oapi1 = openapi(document1)
export const oapi2 = openapi(document2)

app.use(document1)

app.get("/endpoint", oapi1.validPath({ ... }))
app.get("/other/endpoint", oapi2.validPath({ ... }))

The resulting openapi spec will include both /endpoint and /other/endpoint and their definitions, even though it was made with a separate middleware.

henry232323 avatar Oct 22 '25 02:10 henry232323