Automatically generates OpenAPI (Swagger) specifications for Express.js 4.x REST APIs from runtime request/response analysis. Version 1.0.48 provides both Swagger UI and spec endpoints, supports OpenAPI 2 and 3 (default v2), and allows customization via merge objects or callback functions. Releases follow a maintenance cadence with limited recent activity. Key differentiators: no manual annotation required, works with existing routes, supports Mongoose model integration for definitions (requires mongoose, mongoose-to-swagger, bson as peer deps). Full TypeScript definitions included. Note: spec generation is reactive—must exercise endpoints before specs appear.
npm install express-oas-generatorNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initializes express-oas-generator with Express app, then defines a simple route. Open Swagger UI at /api-docs after hitting endpoints.
Exercise your API (e.g., with tests or curl) to populate the spec.
If you need OpenAPI 3, access /api-docs/v3 or /api-spec/v3 explicitly.
Ensure all three are in package.json dependencies.
Provide at least an empty object: init(app, {}).Call init() after defining all routes, or ensure routes are registered before first request.
Make at least one request to your API before accessing /api-spec.
Use default import: import expressOasGenerator from 'express-oas-generator' or const expressOasGenerator = require('express-oas-generator').Initialize mongoose models before calling init(), or use mongoose.modelNames() after model registration.
Ensure file path is provided as third argument to init() and wait for write interval (default 10s).