3
3
4
4
5
5
- [ 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 )
9
9
- [ The script] ( #the-script )
10
- - [ Config file] ( #config-file )
10
+ - [ Config file : gear : ] ( #config-file-gear )
11
11
- [ Create the config file (you choose the name and the location)] ( #create-the-config-file-you-choose-the-name-and-the-location )
12
12
- [ 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 )
15
18
- [ Run with watch (internet file)] ( #run-with-watch-internet-file )
16
19
- [ Run with watch (local file)] ( #run-with-watch-local-file )
17
20
18
- ## Description
21
+ ## Description : scroll :
19
22
20
23
This script is written in ` TypeScript ` , it can generate all ` Models ` and ` APIs ` (serivces) in any kind of language.
21
24
@@ -25,7 +28,7 @@ You can modify those files to adapt to your code.
25
28
26
29
It's planned for a future to let configure this script instead need to modify the source code.
27
30
28
- ## Installation
31
+ ## Installation : electric_plug :
29
32
30
33
``` bash
31
34
npm i @protocolnebula/ts-openapi-generator
@@ -39,32 +42,42 @@ mkdir -p src/generatedApi
39
42
cp -r node_modules/ts-openapi-generator/ApiBase src/generatedApi/ApiBase
40
43
```
41
44
42
- ## Usage
45
+ ## Usage : hammer_and_pick :
43
46
44
47
### The script
45
48
46
49
Is recommended to add a script to your ` package.json ` or package manager that you use.
47
50
48
51
> 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.
49
55
50
56
``` 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
52
63
```
53
64
54
- ### Config file
65
+ ### Config file : gear :
55
66
56
67
> The settings of the config file are the same than cli one (but in ` camelCase ` ).
57
68
58
69
#### Create the config file (you choose the name and the location)
59
70
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.
61
72
62
73
``` json
63
74
{
64
75
"clean" : true ,
65
76
"file" : " ./examples/openApiFiles/passportescaperoom.com.json" ,
66
77
"outputFolder" : " ./examples/generated/angular2" ,
67
78
"template" : " angular2" ,
79
+ "mock-generator" : " json-server" ,
80
+ "mock-output" : " examples/generated/mocks/json-server" ,
68
81
"saveFile" : " ./openApiFiles/passportescaperoom.com"
69
82
}
70
83
```
@@ -75,15 +88,21 @@ We will name for example `transfrom-config.json`
75
88
transform-swagger --config-file ./examples/transform-config.json
76
89
```
77
90
78
- ### Main CLI commands
91
+ ### Main CLI commands : open_book :
79
92
80
93
``` bash
81
94
Usage: transform-swagger [options]
82
95
83
96
Options:
84
97
--version, -v Show version number [boolean]
85
98
--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]
87
106
--clean No clean the output-folder, so old files will remain
88
107
[boolean] [default: true]
89
108
-f, --file Path OR URL to the swagger document to parse [required]
@@ -98,7 +117,24 @@ Examples:
98
117
compatible-angular API
99
118
```
100
119
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 :
102
138
103
139
### Run with watch (internet file)
104
140
0 commit comments