1.3.4 • Published 8 months ago
@pmg1989/openapi-typescript-codegen v1.3.4
OpenAPI Typescript Codegen
Node.js library that generates Typescript clients based on the OpenAPI specification.
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, Node-Fetch, Axios, Angular and XHR http clients
- Supports OpenAPI specification v2.0 and v3.0
- Supports JSON and YAML files for input
- Supports generation through CLI, Node.js and NPX
- Supports tsc and @babel/plugin-transform-typescript
- Supports aborting of requests (cancelable promise pattern)
- Supports external references using json-schema-ref-parser
Install
npm install @pmg1989/openapi-typescript-codegen --save-dev
Usage
$ openapi --help
Usage: openapi [options]
Options:
-V, --version output the version number
-i, --input <value> OpenAPI specification, can be a path, url or string content (required)
-o, --output <value> Output directory (required)
-c, --client <value> HTTP client to generate [fetch, xhr, node, axios, angular, nestjs, requestBff] (default: "fetch")
--name <value> Custom client class name
--useOptions Use options instead of arguments
--useUnionTypes Use union types instead of enums
--exportCore <value> Write core files to disk (default: true)
--exportServices <value> Write services to disk (default: true)
--exportModels <value> Write models to disk (default: true)
--exportSchemas <value> Write schemas to disk (default: false)
--indent <value> Indentation options [4, 2, tab] (default: "4")
--postfixServices Service name postfix (default: "Service")
--postfixModels Model name postfix
--request <value> 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
Documentation
- Basic usage
- OpenAPI object
- Client instances
--name
- Argument vs. Object style
--useOptions
- Enums vs. Union types
--useUnionTypes
- Runtime schemas
--exportSchemas
- Enum with custom names and descriptions
- Nullable props (OpenAPI v2)
- Authorization
- External references
- Canceling requests
- Custom request file
Support
1.3.4
8 months ago
1.3.3
8 months ago
1.3.2
8 months ago
1.2.3
10 months ago
1.3.1
8 months ago
1.2.2
10 months ago
1.2.0
11 months ago
1.1.6
11 months ago
1.1.5
11 months ago
1.2.1
11 months ago
1.1.4
1 year ago
1.1.3
2 years ago
1.1.1
2 years ago
1.1.0
2 years ago
1.1.2
2 years ago
1.0.8
2 years ago
1.0.7
2 years ago
1.0.6
2 years ago
1.0.5
2 years ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago