very-express 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/dist/generators/openapi.generator.js +10 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,19 @@ an generator that generate [Express](https://github.com/expressjs/express) rest-
|
|
|
5
5
|
doing same things once is good,
|
|
6
6
|
twice is okay, third times is wasting life.
|
|
7
7
|
|
|
8
|
-
all you need is define the `JsonSchema` and `openApi` spec
|
|
8
|
+
all you need is define the `JsonSchema` and `openApi` spec
|
|
9
|
+
|
|
10
|
+
# Quick Start
|
|
11
|
+
1. create JsonSchmea, can refer to output/jsonSchema put it as cli config file
|
|
12
|
+
2. `npm i -g very-express`
|
|
13
|
+
install package globally
|
|
14
|
+
3. `vex -h`
|
|
15
|
+
this cmd create the cli config file
|
|
16
|
+
4. `vex `
|
|
17
|
+
call cli with vex.config.json setting
|
|
18
|
+
5. `npm i`
|
|
19
|
+
6. `npm build`
|
|
20
|
+
7. `npm run start`
|
|
9
21
|
|
|
10
22
|
## JsonSchmea Setup
|
|
11
23
|
at the root of schema :
|
|
@@ -119,13 +119,22 @@ function jsonToOpenapiPath(openapiJson, jsonSchema) {
|
|
|
119
119
|
};
|
|
120
120
|
routes[route][method].parameters = [idParameter];
|
|
121
121
|
if (method == types.method.get) {
|
|
122
|
-
routes[route + '/{id}'][method] = routes[route][method];
|
|
122
|
+
routes[route + '/{id}'][method] = Object.assign({}, routes[route][method]);
|
|
123
123
|
routes[route + '/{id}'][method].responses[200].content["application/json"].schema.$ref = `#/components/schemas/${method}${interfaceName}Response`;
|
|
124
124
|
routes[route + '/{id}'][method].parameters = [idParameter];
|
|
125
125
|
}
|
|
126
126
|
;
|
|
127
127
|
}
|
|
128
128
|
;
|
|
129
|
+
if (method == types.method.post) {
|
|
130
|
+
routes[route][method].responses[201] = routes[route][method].responses[200];
|
|
131
|
+
routes[route][method].responses[201].description = 'Crerated';
|
|
132
|
+
delete routes[route][method].responses[200];
|
|
133
|
+
}
|
|
134
|
+
else if (method == types.method.delete) {
|
|
135
|
+
delete routes[route][method].responses[200].content;
|
|
136
|
+
}
|
|
137
|
+
;
|
|
129
138
|
if (useBody) {
|
|
130
139
|
routes[route][method].requestBody = {
|
|
131
140
|
description: `${method} ${documentConfig.documentName}`,
|
|
@@ -136,15 +145,6 @@ function jsonToOpenapiPath(openapiJson, jsonSchema) {
|
|
|
136
145
|
};
|
|
137
146
|
}
|
|
138
147
|
;
|
|
139
|
-
if (method == types.method.post) {
|
|
140
|
-
routes[route][method].responses[201] = routes[route][method].responses[200];
|
|
141
|
-
routes[route][method].responses[201].description = 'Crerated';
|
|
142
|
-
delete routes[route][method].responses[200];
|
|
143
|
-
}
|
|
144
|
-
else if (method == types.method.delete) {
|
|
145
|
-
delete routes[route][method].responses[200].content;
|
|
146
|
-
}
|
|
147
|
-
;
|
|
148
148
|
});
|
|
149
149
|
openapiJson.paths = Object.assign(openapiJson.paths, routes);
|
|
150
150
|
return openapiJson;
|