4.5.0 • Published 16 days ago

rest2ts v4.5.0

Weekly downloads
2
License
ISC
Repository
github
Last release
16 days ago

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.

4.4.0

17 days ago

4.5.0

16 days ago

4.3.2

1 month ago

4.3.1

1 month ago

4.3.0

1 month ago

4.2.5

1 month ago

4.2.4

2 months ago

4.2.3

3 months ago

4.2.2

3 months ago

3.0.1

6 months ago

3.0.0

6 months ago

4.0.5

6 months ago

4.0.4

6 months ago

4.0.7

6 months ago

4.0.6

6 months ago

4.0.1

6 months ago

4.0.0

6 months ago

4.2.1

4 months ago

4.0.3

6 months ago

4.2.0

5 months ago

4.0.2

6 months ago

4.0.8

6 months ago

3.1.0

6 months ago

4.1.3

5 months ago

4.1.0

5 months ago

4.1.2

5 months ago

4.1.1

5 months ago

2.0.3

10 months ago

2.2.0

9 months ago

2.0.5

10 months ago

2.4.0

7 months ago

2.0.4

10 months ago

2.0.7

9 months ago

2.0.6

10 months ago

2.3.0

9 months ago

2.3.2

7 months ago

2.3.1

8 months ago

2.3.3

7 months ago

2.1.0

9 months ago

1.8.2

1 year ago

1.8.1

1 year ago

1.8.0

1 year ago

2.0.2

12 months ago

2.0.1

12 months ago

2.0.0

12 months ago

1.7.3

1 year ago

1.9.0

1 year ago

1.7.2

1 year ago

1.7.1

1 year ago

1.7.0

1 year ago

1.6.1

2 years ago

1.6.0

2 years ago

1.5.0

2 years ago

1.4.1

2 years ago

1.4.0

3 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.11

4 years ago

1.2.9

4 years ago

1.2.10

4 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.0.11

4 years ago

1.0.9

4 years ago

1.0.10

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago