Axios and Angular REST API client generator from OpenAPI v3 (YAML or JSON) and WADL. Generated files are compatible with Axios or Angular v8/9, depending on your settings.
The package generates an TypeScript classes and request callings for Axios (or Angular) from an OpenAPI v3 (or WADL) specification file. The code is generated using Handlebar templates.
This option installs package globally and you can run it directly from your terminal.
npm install client-services-generator -g
This option installs package only to your project.
npm install client-services-generator --save-dev
If you installed package globally, you can run it from your terminal accordingly:
client-services-generator -s ./apiDocs/openApi.json -t axios -o ./myApp
If you installed it only to your project, create this simple script in your package.json:
"scripts": {
"client-services-generator": "client-services-generator -s ./apiDocs/openApi.json -t axios -o ./myApp",
},
Then just run:
npm run client-services-generator
Option | Description | Default value | Type |
---|---|---|---|
--version |
Show version number | ||
-h / --help |
Show help | [boolean] | |
-i / --interactive * |
Runs program in interactive mode | false |
[boolean] |
-s / --source * |
Path to source file (api documentation) | "" |
[string] |
-t / --type |
Output type of services | axios |
[axios, angular] |
-o / --output |
Path to output directory for generated service files. | (current path) |
[string] |
* (One of arguments 'i' or 's' is required.)
output-path/services
├─ models
│ ├─ myEnum.ts
│ ├─ myModel.ts
│ │ ...
│ └─ anotherModel.ts
├─ requests
│ ├─ myRequests.ts
│ │ ...
│ └─ anotherRequests.ts
└─ serviceBase.ts