Skip to content

@routup/swagger

Two things in one plugin:

  1. Generator — walk a TypeScript codebase, extract route metadata via @trapi/metadata, and emit an OpenAPI v2 or v3 document.
  2. UI — mount Swagger UI at any path to serve the generated document interactively.

Pair with @routup/decorators (controllers and parameter decorators are the source of truth) and @routup/swagger-preset (which teaches the generator how to interpret routup's @D* decorators).

Installation

bash
npm install @routup/swagger @routup/swagger-preset

When to use it

  • You want OpenAPI docs that stay in sync with your handlers — the generator reads the same decorators that mount the routes
  • You want Swagger UI inline in the same routup app, no separate process
  • You're publishing a public API and need a contract artifact for client codegen

If you're hand-writing your OpenAPI document (or generating it from another source), you only need the UI half — skip the generator and feed swaggerUI() your existing swagger.json / openapi.yaml.

See also

  • Generatorgenerate(), V2 vs V3, output paths
  • UIswaggerUI(), mounting, custom UI options
  • @routup/swagger-preset — the @trapi/metadata preset that decodes @DController / @DGet / @DBody
  • @routup/decorators — write controllers in the shape the generator expects

Released under the MIT License.