33
44
55- [ TypeScript OpenApi/Swagger Generator] ( #typescript-openapiswagger-generator )
6- - [ Description] ( #description )
7- - [ Installation] ( #installation )
8- - [ Usage] ( #usage )
6+ - [ Description : scroll : ] ( #description-scroll )
7+ - [ Installation : electric_plug : ] ( #installation-electric_plug )
8+ - [ Usage : hammer_and_pick : ] ( #usage-hammer_and_pick )
99 - [ The script] ( #the-script )
10- - [ Config file] ( #config-file )
10+ - [ Config file : gear : ] ( #config-file-gear )
1111 - [ Create the config file (you choose the name and the location)] ( #create-the-config-file-you-choose-the-name-and-the-location )
1212 - [ Launch the script] ( #launch-the-script )
13- - [ Main CLI commands] ( #main-cli-commands )
14- - [ Development] ( #development )
13+ - [ Main CLI commands :open_book : ] ( #main-cli-commands-open_book )
14+ - [ Supported generators :toolbox : ] ( #supported-generators-toolbox )
15+ - [ API/Models] ( #apimodels )
16+ - [ Mock engine] ( #mock-engine )
17+ - [ Development :memo : ] ( #development-memo )
1518 - [ Run with watch (internet file)] ( #run-with-watch-internet-file )
1619 - [ Run with watch (local file)] ( #run-with-watch-local-file )
1720
18- ## Description
21+ ## Description : scroll :
1922
2023This script is written in ` TypeScript ` , it can generate all ` Models ` and ` APIs ` (serivces) in any kind of language.
2124
@@ -25,7 +28,7 @@ You can modify those files to adapt to your code.
2528
2629It's planned for a future to let configure this script instead need to modify the source code.
2730
28- ## Installation
31+ ## Installation : electric_plug :
2932
3033``` bash
3134npm i @protocolnebula/ts-openapi-generator
@@ -39,32 +42,42 @@ mkdir -p src/generatedApi
3942cp -r node_modules/ts-openapi-generator/ApiBase src/generatedApi/ApiBase
4043```
4144
42- ## Usage
45+ ## Usage : hammer_and_pick :
4346
4447### The script
4548
4649Is recommended to add a script to your ` package.json ` or package manager that you use.
4750
4851> Change ` src/generatedApi ` by your desired folder to generate the code.
52+ > If you not specify ` mock-output ` , ` -o + mock/ ` will be used.
53+
54+ > Note that ` -t ` (template) and ` --mock-engine ` are optional, you can only use some of them.
4955
5056``` bash
51- transform-swagger -f URI/TO/SWAGGER/JSON/OR/YAML -o src/generatedApi/ -t angular2
57+ transform-swagger \
58+ -f URI/TO/SWAGGER/JSON/OR/YAML \
59+ -o src/generatedApi/ \
60+ -t angular2 \
61+ --mock-engine json-server \
62+ --mock-output path/to/mock
5263```
5364
54- ### Config file
65+ ### Config file : gear :
5566
5667> The settings of the config file are the same than cli one (but in ` camelCase ` ).
5768
5869#### Create the config file (you choose the name and the location)
5970
60- We will name for example ` transfrom-config.json `
71+ We will use as example [ transfrom-config.json] ( examples/transform-config.json ) example's one.
6172
6273``` json
6374{
6475 "clean" : true ,
6576 "file" : " ./examples/openApiFiles/passportescaperoom.com.json" ,
6677 "outputFolder" : " ./examples/generated/angular2" ,
6778 "template" : " angular2" ,
79+ "mock-generator" : " json-server" ,
80+ "mock-output" : " examples/generated/mocks/json-server" ,
6881 "saveFile" : " ./openApiFiles/passportescaperoom.com"
6982}
7083```
@@ -75,15 +88,21 @@ We will name for example `transfrom-config.json`
7588transform-swagger --config-file ./examples/transform-config.json
7689```
7790
78- ### Main CLI commands
91+ ### Main CLI commands : open_book :
7992
8093``` bash
8194Usage: transform-swagger [options]
8295
8396Options:
8497 --version, -v Show version number [boolean]
8598 --config-file Configuration file to use (values from cli will overwrite
86- the files one).
99+ this file).
100+ --mock-generator Specify the generator to use to generate mocks. If none
101+ provider, mocks will not be generated
102+ --mock-output The path where mock will be generated. If no specified,
103+ output-folder/mock will be used
104+ --mock-partial If true, only mock data will be generated instead of all
105+ files [boolean] [default: false]
87106 --clean No clean the output-folder, so old files will remain
88107 [boolean] [default: true]
89108 -f, --file Path OR URL to the swagger document to parse [required]
@@ -98,7 +117,24 @@ Examples:
98117 compatible-angular API
99118```
100119
101- ## Development
120+ ## Supported generators :toolbox :
121+ ### API/Models
122+
123+ > ` Plugin name ` refers to the ` template ` parameter (` -t ` or ` --template ` in the cli)
124+
125+ | Language/Framework | Status | Plugin name (-t) |
126+ | --------------------| --------| ------------------|
127+ | Angular 2 | Beta | ` angular2 ` |
128+
129+ ### Mock engine
130+
131+ > ` Generator name ` refers to the ` mock-generator ` parameter (` --mock-generator ` in the cli)
132+
133+ | Engine | Status | Generator name (--mock-generator) |
134+ | --------| --------| -----------------------------------|
135+ | json-server | Beta | ` json-server ` |
136+
137+ ## Development :memo :
102138
103139### Run with watch (internet file)
104140
0 commit comments