NodeJS library that generates Typescript or Javascript clients based on the OpenAPI specification.
npm install @lsongzhi/openapi-typescript-codegen




> NodeJS library that generates Typescript clients based on the OpenAPI specification.
x-enum-varnames: string[] and x-enum-descriptions in schema to generate enums with names and descriptions in the field.#### Why?
- Frontend ❤️ OpenAPI, but we do not want to use JAVA codegen in our builds.
- Quick, lightweight, robust and framework agnostic.
- Supports generation of Typescript clients.
- Supports generations of fetch and XHR http clients.
- Supports OpenAPI specification v2.0 and v3.0.
- Supports JSON and YAML files for input.
```
npm install @lsongzhi/openapi-typescript-codegen --save-dev
package.json
`json`
{
"scripts": {
"generate": "openapi --input ./api/openapi.json --output ./dist"
}
...
}
Command line
`
npm install openapi-typescript-codegen -g
openapi ./api/openapi.json ./dist
`
NodeJS API:
`
const OpenAPI = require('openapi-typescript-codegen');
OpenAPI.generate(
'./api/openapi.json',
'./dist'
);
``