@nwire/openapi
v0.15.1
Published
Nwire — OpenAPI 3.1 generation from a Nwire wire collection. Transport-agnostic: reads app.interface.wires, picks the HTTP bindings, and emits a spec from binding metadata + zod schemas. Owns @asteasolutions/zod-to-openapi as a direct dependency, so any H
Downloads
443
Readme
@nwire/openapi
OpenAPI 3.1 generation from a Nwire wire collection — transport-agnostic.
pnpm add @nwire/openapigenerateOpenApi(wires) reads app.interface.wires, picks the HTTP bindings,
and emits an OpenAPI 3.1 document from each binding's openapi metadata and its
zod schemas. No HTTP server and no framework lock-in: an HTTP adopter (koa,
express) serves the result, and a build step can write it to a file without
booting a transport.
import { generateOpenApi } from "@nwire/openapi";
const spec = await generateOpenApi(app.interface.wires, {
title: "Orders API",
version: "1.0.0",
prefix: "/api",
});
// serve `JSON.stringify(spec)` at /openapi.json, or write it to diskThis package owns @asteasolutions/zod-to-openapi as a direct dependency, so the
generator is always present where generation lives and a consumer produces a spec
with nothing extra to install.
Options
| Option | Meaning |
| ----------------------------------- | ----------------------------------------------------------------------- |
| title / version / description | info block of the document |
| serverUrl | a single entry for the servers array |
| prefix | path prefix prepended to every route (match your HTTP adopter's prefix) |
Bindings carry the rest: operation, summary, tags, request schemas
(params / query / body), and returns / errors for responses.
