rest2ts v4.5.0
Rest2ts
Rest2ts is a simple npm library that generates TypeScript client code from a Swagger/OpenAPI definition file. It allows you to create type-safe API clients for your projects.
Features
- Generates TypeScript code from Swagger/OpenAPI definition files
- Supports nullable strings with the `nullstr` flag
- Optional base URL setting for generated code
Installation
To install the library, run the following command:
npm install -g rest2ts
Usage
To generate TypeScript code from a Swagger/OpenAPI definition file, use the following command:
rest2ts -s path/to/swagger.json -t target/path
Command-line Options
-h, --help
: Displays help information-s, --source
: Path to the Swagger/OpenAPI definition file-t, --target
: Target path for generated TypeScript code-v, --urlValue
: Base URL value used in generated code, can be a string or a node global value-f, --fileName
: Output file name. Default file name is Api.ts.--nullstr, --areNullableStringsEnabled
: Enable or disable nullable strings. Set to 1 to enable and 0 to disable.--ng, --generateForAngular
: Set to 1 to generate Typescript code for Angular with HttpClient and Rxjs. UrlValue is provided by API_BASE_URL InjectionToken.
Example
rest2ts -s https://api.example.com/swagger.json -t ./src/api
Generated Code
The generated TypeScript code will be placed in the target directory specified by the `-t` flag. The file will be named `Api.ts`.
Contributing
We welcome contributions to Rest2ts. If you find a bug or have a feature request, please open an issue on the repository.
License
Rest2ts is released under the MIT License.
17 days ago
16 days ago
1 month ago
1 month ago
1 month ago
1 month ago
2 months ago
3 months ago
3 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
4 months ago
6 months ago
5 months ago
6 months ago
6 months ago
6 months ago
5 months ago
5 months ago
5 months ago
5 months ago
10 months ago
9 months ago
10 months ago
7 months ago
10 months ago
9 months ago
10 months ago
9 months ago
7 months ago
8 months ago
7 months ago
9 months ago
1 year ago
1 year ago
1 year ago
12 months ago
12 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago