Library that generates Typescript clients based on the OpenAPI specification.
npm install @nexnox/openapi-typescript-codegen
npm install openapi-typescript-codegen --save-dev
`
Usage
`
$ openapi --help
Usage: openapi [options]
Options:
-V, --version output the version number
-i, --input OpenAPI specification, can be a path, url or string content (required)
-o, --output Output directory (required)
-c, --client HTTP client to generate [fetch, xhr, node, axios, angular] (default: "fetch")
--name Custom client class name
--useOptions Use options instead of arguments
--useUnionTypes Use union types instead of enums
--exportCore Write core files to disk (default: true)
--exportServices Write services to disk (default: true)
--exportModels Write models to disk (default: true)
--exportSchemas Write schemas to disk (default: false)
--indent Indentation options [4, 2, tab] (default: "4")
--postfixServices Service name postfix (default: "Service")
--postfixModels Model name postfix
--request Path to custom request file
-h, --help display help for command
Examples
$ openapi --input ./spec.json --output ./generated
$ openapi --input ./spec.json --output ./generated --client xhr
`
Docker usage
To build the Docker container, execute the following command:
`
docker build . --tag openapi-typescript-codegen
`
After this is done, you can execute the CLI commands:
`
docker run openapi-typescript-codegen --help
docker run openapi-typescript-codegen --input sample.yaml --output client
`
Documentation
===
- Basic usage
- OpenAPI object
- Client instances --name
- Argument vs. Object style --useOptions
- Enums vs. Union types --useUnionTypes
- Runtime schemas --exportSchemas`