@guren/openapi
v1.4.2
Published
OpenAPI 3.1 document generation from Guren route contracts.
Maintainers
Readme
@guren/openapi
OpenAPI 3.1 document generation from Guren route contracts. Optional: install it when you want a spec, and the CLI command appears.
bun add @guren/openapiGenerating a document
Routes that attach Zod schemas through RouteContractOptions (body, params, query) carry enough type information to describe themselves, so the document is derived from the routes rather than written beside them:
bunx guren openapi:generate
bunx guren openapi:generate --title "Blog API" --version "1.0.0"
bunx guren openapi:generate --routes routes/api.ts --out docs/openapi.jsonWithout arguments it reads routes/web.ts and writes .guren/openapi.gen.json.
API
Each takes the route definitions to describe, so a build step can generate a document for any set of routes rather than only the one the CLI reads:
generateOpenApiDocument(definitions, options)— returns the document as an object, for a build step that needs to post-process it.writeOpenApiDocument(definitions, options)— generates and writes it to a path.mountOpenApiDocs(app, options)— serves the document, and a documentation viewer, from the running app.
Documentation
The Ship an API guide covers route contracts, and the CLI guide documents every openapi:generate option.
License
MIT
