1.0.1 • Published 4 years ago

client-services-generator v1.0.1

Weekly downloads
3
License
GPL-3.0
Repository
github
Last release
4 years ago

Client services generator

npm version

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.

Description

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.

Installation

Command Line

This option installs package globally and you can run it directly from your terminal.

npm install client-services-generator -g

NodeJS/Browser

This option installs package only to your project.

npm install client-services-generator --save-dev

Usage

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

Options

OptionDescriptionDefault valueType
--versionShow version number
-h / --helpShow helpboolean
-i / --interactive *Runs program in interactive modefalseboolean
-s / --source *Path to source file (api documentation)""string
-t / --typeOutput type of servicesaxiosaxios, angular
-o / --outputPath to output directory for generated service files.(current path)string

* (One of arguments 'i' or 's' is required.)

Generated structure

output-path/services
 ├─ models
 │   ├─ myEnum.ts
 │   ├─ myModel.ts
 │   │  ...
 │   └─ anotherModel.ts
 ├─ requests
 │   ├─ myRequests.ts
 │   │  ...
 │   └─ anotherRequests.ts
 └─ serviceBase.ts