nestia 2.1.7 → 2.1.10

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.
@@ -1 +1 @@
1
- {"version":3,"file":"SwaggerGenerator.d.ts","sourceRoot":"","sources":["../../src/generates/SwaggerGenerator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAC;AAS5B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAM9C,yBAAiB,gBAAgB,CACjC;IACI,SAAsB,QAAQ,CAEtB,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,MAAM,EAAE,cAAc,CAAC,QAAQ,EAC/B,SAAS,EAAE,MAAM,EAAE,GACpB,OAAO,CAAC,IAAI,CAAC,CAsCnB;CAgOJ"}
1
+ {"version":3,"file":"SwaggerGenerator.d.ts","sourceRoot":"","sources":["../../src/generates/SwaggerGenerator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAC;AAS5B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAO9C,yBAAiB,gBAAgB,CACjC;IACI,SAAsB,QAAQ,CAEtB,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,MAAM,EAAE,cAAc,CAAC,QAAQ,EAC/B,SAAS,EAAE,MAAM,EAAE,GACpB,OAAO,CAAC,IAAI,CAAC,CA6CnB;CAgOJ"}
@@ -91,10 +91,10 @@ var SwaggerGenerator;
91
91
  (function (SwaggerGenerator) {
92
92
  function generate(checker, config, routeList) {
93
93
  return __awaiter(this, void 0, void 0, function () {
94
- var parsed, location, swagger, collection, pathDict, routeList_1, routeList_1_1, route, path, pathDict_1, pathDict_1_1, _a, path, routes;
95
- var e_1, _b, e_2, _c;
96
- return __generator(this, function (_d) {
97
- switch (_d.label) {
94
+ var parsed, location, swagger, collection, pathDict, routeList_1, routeList_1_1, route, path, pathDict_1, pathDict_1_1, _a, path, routes, _b, _c, object;
95
+ var e_1, _d, e_2, _e, e_3, _f;
96
+ return __generator(this, function (_g) {
97
+ switch (_g.label) {
98
98
  case 0:
99
99
  parsed = path_1.default.parse(config.output);
100
100
  location = !!parsed.ext
@@ -102,7 +102,7 @@ var SwaggerGenerator;
102
102
  : path_1.default.join(path_1.default.resolve(config.output), "swagger.json");
103
103
  return [4 /*yield*/, initialize(location)];
104
104
  case 1:
105
- swagger = _d.sent();
105
+ swagger = _g.sent();
106
106
  collection = new MetadataCollection_1.MetadataCollection(false);
107
107
  pathDict = new Map();
108
108
  try {
@@ -115,7 +115,7 @@ var SwaggerGenerator;
115
115
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
116
116
  finally {
117
117
  try {
118
- if (routeList_1_1 && !routeList_1_1.done && (_b = routeList_1.return)) _b.call(routeList_1);
118
+ if (routeList_1_1 && !routeList_1_1.done && (_d = routeList_1.return)) _d.call(routeList_1);
119
119
  }
120
120
  finally { if (e_1) throw e_1.error; }
121
121
  }
@@ -129,14 +129,31 @@ var SwaggerGenerator;
129
129
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
130
130
  finally {
131
131
  try {
132
- if (pathDict_1_1 && !pathDict_1_1.done && (_c = pathDict_1.return)) _c.call(pathDict_1);
132
+ if (pathDict_1_1 && !pathDict_1_1.done && (_e = pathDict_1.return)) _e.call(pathDict_1);
133
133
  }
134
134
  finally { if (e_2) throw e_2.error; }
135
135
  }
136
+ // CONSTRUCT COMPONENTS
136
137
  swagger.components = SchemaFactory_1.SchemaFactory.components(collection.storage());
138
+ try {
139
+ for (_b = __values(Object.values(swagger.components.schemas)), _c = _b.next(); !_c.done; _c = _b.next()) {
140
+ object = _c.value;
141
+ if (object.$id)
142
+ delete object.$id;
143
+ }
144
+ }
145
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
146
+ finally {
147
+ try {
148
+ if (_c && !_c.done && (_f = _b.return)) _f.call(_b);
149
+ }
150
+ finally { if (e_3) throw e_3.error; }
151
+ }
152
+ // DO GENERATE
137
153
  return [4 /*yield*/, fs_1.default.promises.writeFile(location, JSON.stringify(swagger, null, 2), "utf8")];
138
154
  case 2:
139
- _d.sent();
155
+ // DO GENERATE
156
+ _g.sent();
140
157
  return [2 /*return*/];
141
158
  }
142
159
  });
@@ -178,7 +195,7 @@ var SwaggerGenerator;
178
195
  });
179
196
  }
180
197
  function get_path(path, parameters) {
181
- var e_3, _a;
198
+ var e_4, _a;
182
199
  var filtered = parameters.filter(function (param) { return param.category === "param"
183
200
  && !!param.field; });
184
201
  try {
@@ -187,12 +204,12 @@ var SwaggerGenerator;
187
204
  path = path.replace(":".concat(param.field), "{".concat(param.field, "}"));
188
205
  }
189
206
  }
190
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
207
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
191
208
  finally {
192
209
  try {
193
210
  if (filtered_1_1 && !filtered_1_1.done && (_a = filtered_1.return)) _a.call(filtered_1);
194
211
  }
195
- finally { if (e_3) throw e_3.error; }
212
+ finally { if (e_4) throw e_4.error; }
196
213
  }
197
214
  return path;
198
215
  }
@@ -228,7 +245,7 @@ var SwaggerGenerator;
228
245
  --------------------------------------------------------- */
229
246
  function generate_parameter(checker, collection, route, parameter) {
230
247
  return {
231
- name: parameter.name,
248
+ name: parameter.field || parameter.name,
232
249
  in: parameter.category === "param"
233
250
  ? "path"
234
251
  : parameter.category,
@@ -240,7 +257,7 @@ var SwaggerGenerator;
240
257
  function generate_request_body(checker, collection, route, parameter) {
241
258
  return {
242
259
  description: warning.get(parameter.encrypted).get("request")
243
- + get_parametric_description(route, "param", parameter.name) || "",
260
+ + (get_parametric_description(route, "param", parameter.name) || ""),
244
261
  content: {
245
262
  "application/json": {
246
263
  schema: generate_schema(checker, collection, parameter.type.metadata)
@@ -259,9 +276,9 @@ var SwaggerGenerator;
259
276
  var success = (_a = {},
260
277
  _a[status] = {
261
278
  description: warning.get(route.encrypted).get("response", route.method)
262
- + get_parametric_description(route, "return")
263
- || get_parametric_description(route, "returns")
264
- || "",
279
+ + (get_parametric_description(route, "return")
280
+ || get_parametric_description(route, "returns")
281
+ || ""),
265
282
  content: route.output.escapedText === "void" ? undefined :
266
283
  {
267
284
  "application/json": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nestia",
3
- "version": "2.1.7",
3
+ "version": "2.1.10",
4
4
  "description": "Automatic SDK and Document generator for the NestJS",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -41,7 +41,7 @@
41
41
  "tsconfig-paths": "^3.14.1",
42
42
  "tstl": "^2.5.6",
43
43
  "ttypescript": "^1.5.13",
44
- "typescript": "^4.6.3",
44
+ "typescript": "^4.7.2",
45
45
  "typescript-is": "^0.19.0",
46
46
  "typescript-json": "^2.1.3",
47
47
  "typescript-transform-paths": "^3.3.1"