Render an OpenAPI specification
An io-ts-http
specification contains a superset of an OpenAPI specification.
api-ts
provides @api-ts/openapi-generator
to produce an OpenAPI specification from
your io-ts-http
API specification. This lets you plug your API specification into the
existing OpenAPI ecosystem to HTTP clients for languages other than TypeScript. These
clients won't be as ergonomic or type-safe as an api-ts
HTTP client.
Use openapi-generator
As before, first edit your package.json
file to add our new dependencies
(highlighted):
And install it by running:
$ npm install
The openapi-generator
requires our TypeScript compiler settings to be specified in a
tsconfig.json
file, so create one like this:
Invoke the openapi-generator
by running:
$ npx openapi-generator --input ./index.ts --output ./api.json
This will produce a file api.json
with the following content: