@rxap/schematics-open-api 13.1.0 → 13.1.2

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/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [13.1.2](https://gitlab.com/rxap/packages/compare/@rxap/schematics-open-api@13.1.1...@rxap/schematics-open-api@13.1.2) (2022-11-30)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * use any return type ([44afb5b](https://gitlab.com/rxap/packages/commit/44afb5bd7a906e6e532efe9821c88b54063eeb3d))
12
+
13
+
14
+
15
+
16
+
17
+ ## [13.1.1](https://gitlab.com/rxap/packages/compare/@rxap/schematics-open-api@13.1.0...@rxap/schematics-open-api@13.1.1) (2022-11-30)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * async generator execution ([18153d8](https://gitlab.com/rxap/packages/commit/18153d8878918ed2e8604a213a015e697729791c))
23
+
24
+
25
+
26
+
27
+
6
28
  # [13.1.0](https://gitlab.com/rxap/packages/compare/@rxap/schematics-open-api@13.0.0...@rxap/schematics-open-api@13.1.0) (2022-11-30)
7
29
 
8
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rxap/schematics-open-api",
3
- "version": "13.1.0",
3
+ "version": "13.1.2",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.1",
6
6
  "semver": "^7.3.5"
@@ -1,3 +1,3 @@
1
1
  import { OpenAPIV3 } from 'openapi-types';
2
2
  import { Project } from 'ts-morph';
3
- export declare function GenerateComponents(components: OpenAPIV3.ComponentsObject, project: Project): Promise<void>;
3
+ export declare function GenerateComponents(components: OpenAPIV3.ComponentsObject, project: Project): Array<Promise<void>>;
@@ -4,21 +4,26 @@ exports.GenerateComponents = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const json_schema_to_typescript_1 = require("@rxap/json-schema-to-typescript");
6
6
  const config_1 = require("./config");
7
- function GenerateComponents(components, project) {
7
+ function executeInterfaceBuild(components, project, schema, name) {
8
8
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
9
- if (components.schemas) {
10
- for (const [name, schema] of Object.entries(components.schemas)) {
11
- const generator = new json_schema_to_typescript_1.TypescriptInterfaceGenerator(Object.assign(Object.assign({}, schema), { components }), { basePath: config_1.COMPONENTS_BASE_PATH }, project);
12
- console.debug(`Generate component interface for: ${name}`);
13
- try {
14
- yield generator.build(name);
15
- }
16
- catch (error) {
17
- console.error(`Failed to generate response interface for: ${name}`, error.message);
18
- }
19
- }
9
+ const generator = new json_schema_to_typescript_1.TypescriptInterfaceGenerator(Object.assign(Object.assign({}, schema), { components }), { basePath: config_1.COMPONENTS_BASE_PATH }, project);
10
+ console.debug(`Generate component interface for: ${name}`);
11
+ try {
12
+ yield generator.build(name);
13
+ }
14
+ catch (error) {
15
+ console.error(`Failed to generate response interface for: ${name}`, error.message);
20
16
  }
21
17
  });
22
18
  }
19
+ function GenerateComponents(components, project) {
20
+ const promiseList = [];
21
+ if (components.schemas) {
22
+ for (const [name, schema] of Object.entries(components.schemas)) {
23
+ promiseList.push(executeInterfaceBuild(components, project, schema, name));
24
+ }
25
+ }
26
+ return promiseList;
27
+ }
23
28
  exports.GenerateComponents = GenerateComponents;
24
29
  //# sourceMappingURL=generate-components.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-components.js","sourceRoot":"","sources":["../../../../../libs/open-api/src/lib/generate-components.ts"],"names":[],"mappings":";;;;AAEA,+EAA+E;AAC/E,qCAAgD;AAEhD,SAAsB,kBAAkB,CACtC,UAAsC,EACtC,OAAgB;;QAGhB,IAAI,UAAU,CAAC,OAAO,EAAE;YACtB,KAAK,MAAM,CAAE,IAAI,EAAE,MAAM,CAAE,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;gBAEjE,MAAM,SAAS,GAAG,IAAI,wDAA4B,iCAC3C,MAAM,KAAE,UAAU,KACvB,EAAE,QAAQ,EAAE,6BAAoB,EAAE,EAClC,OAAO,CACR,CAAC;gBAEF,OAAO,CAAC,KAAK,CAAC,qCAAqC,IAAI,EAAE,CAAC,CAAC;gBAE3D,IAAI;oBAEF,MAAM,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;iBAE7B;gBAAC,OAAO,KAAK,EAAE;oBACd,OAAO,CAAC,KAAK,CAAC,8CAA8C,IAAI,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;iBACpF;aAEF;SACF;IAEH,CAAC;CAAA;AA3BD,gDA2BC"}
1
+ {"version":3,"file":"generate-components.js","sourceRoot":"","sources":["../../../../../libs/open-api/src/lib/generate-components.ts"],"names":[],"mappings":";;;;AACA,+EAA+E;AAG/E,qCAAgD;AAEhD,SAAe,qBAAqB,CAClC,UAAsC,EACtC,OAAgB,EAChB,MAAkB,EAClB,IAAY;;QAGZ,MAAM,SAAS,GAAG,IAAI,wDAA4B,iCAC3C,MAAM,KAAE,UAAU,KACvB,EAAE,QAAQ,EAAE,6BAAoB,EAAE,EAClC,OAAO,CACR,CAAC;QAEF,OAAO,CAAC,KAAK,CAAC,qCAAqC,IAAI,EAAE,CAAC,CAAC;QAE3D,IAAI;YAEF,MAAM,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAE7B;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,8CAA8C,IAAI,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;SACpF;IACH,CAAC;CAAA;AAED,SAAgB,kBAAkB,CAChC,UAAsC,EACtC,OAAgB;IAGhB,MAAM,WAAW,GAAyB,EAAE,CAAC;IAE7C,IAAI,UAAU,CAAC,OAAO,EAAE;QACtB,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;YAC/D,WAAW,CAAC,IAAI,CAAC,qBAAqB,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;SAC5E;KACF;IAED,OAAO,WAAW,CAAC;AAErB,CAAC;AAfD,gDAeC"}
@@ -1,4 +1,4 @@
1
1
  import { OpenAPIV3 } from 'openapi-types';
2
2
  import { Project } from 'ts-morph';
3
- import { OpenApiSchemaBase, GeneratorFunction } from './types';
4
- export declare function GenerateOperation<Options extends OpenApiSchemaBase = OpenApiSchemaBase>(openapi: OpenAPIV3.Document, project: Project, options: Options, generatorFunctionList: GeneratorFunction<Options>[]): Promise<void>;
3
+ import { GeneratorFunction, OpenApiSchemaBase } from './types';
4
+ export declare function GenerateOperation<Options extends OpenApiSchemaBase = OpenApiSchemaBase>(openapi: OpenAPIV3.Document, project: Project, options: Options, generatorFunctionList: GeneratorFunction<Options>[]): Promise<any>;
@@ -2,55 +2,60 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GenerateOperation = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const is_http_method_1 = require("./utilities/is-http-method");
6
- const ignore_operation_1 = require("./utilities/ignore-operation");
7
- const is_operation_object_1 = require("./utilities/is-operation-object");
8
- const types_1 = require("./types");
5
+ const generate_components_1 = require("./generate-components");
9
6
  const generate_parameters_1 = require("./generate-parameters");
10
7
  const generate_request_body_1 = require("./generate-request-body");
11
8
  const generate_response_1 = require("./generate-response");
12
- const generate_components_1 = require("./generate-components");
9
+ const types_1 = require("./types");
10
+ const ignore_operation_1 = require("./utilities/ignore-operation");
11
+ const is_http_method_1 = require("./utilities/is-http-method");
12
+ const is_operation_object_1 = require("./utilities/is-operation-object");
13
+ function executeGenerator(project, options, path, method, generatorFunction, components, operation) {
14
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
15
+ try {
16
+ const parameters = Object.assign(Object.assign({}, operation), { components,
17
+ method,
18
+ path,
19
+ project,
20
+ options });
21
+ yield generatorFunction(parameters);
22
+ }
23
+ catch (e) {
24
+ console.error(`Failed to generate [${generatorFunction === null || generatorFunction === void 0 ? void 0 : generatorFunction.name}] for operation: ${operation.operationId}`);
25
+ }
26
+ });
27
+ }
13
28
  function GenerateOperation(openapi, project, options, generatorFunctionList) {
14
29
  var _a, _b;
15
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
16
- const components = (_b = (_a = openapi.components) !== null && _a !== void 0 ? _a : openapi.definitions) !== null && _b !== void 0 ? _b : {};
17
- yield generate_components_1.GenerateComponents(components, project);
18
- for (const [path, methods] of Object.entries(openapi.paths)) {
19
- if (methods) {
20
- for (const method of Object.keys(methods).filter(is_http_method_1.IsHttpMethod)) {
21
- const operation = methods[method];
22
- if (is_operation_object_1.IsOperationObject(operation)) {
23
- if (ignore_operation_1.IgnoreOperation(['hidden'])(operation)) {
24
- console.log(`Ignore operation '${operation.operationId}'`);
30
+ const components = (_b = (_a = openapi.components) !== null && _a !== void 0 ? _a : openapi.definitions) !== null && _b !== void 0 ? _b : {};
31
+ const promiseList = [];
32
+ promiseList.push(...generate_components_1.GenerateComponents(components, project));
33
+ for (const [path, methods] of Object.entries(openapi.paths)) {
34
+ if (methods) {
35
+ for (const method of Object.keys(methods).filter(is_http_method_1.IsHttpMethod)) {
36
+ const operation = methods[method];
37
+ if (is_operation_object_1.IsOperationObject(operation)) {
38
+ if (ignore_operation_1.IgnoreOperation(['hidden'])(operation)) {
39
+ console.log(`Ignore operation '${operation.operationId}'`);
40
+ }
41
+ else {
42
+ if (types_1.HasOperationId(operation)) {
43
+ promiseList.push(generate_parameters_1.GenerateParameters(operation, project, components));
44
+ promiseList.push(generate_request_body_1.GenerateRequestBody(operation, project, components));
45
+ promiseList.push(generate_response_1.GenerateResponse(operation, project, components));
46
+ for (const generatorFunction of generatorFunctionList) {
47
+ promiseList.push(executeGenerator(project, options, path, method, generatorFunction, components, operation));
48
+ }
25
49
  }
26
50
  else {
27
- if (types_1.HasOperationId(operation)) {
28
- yield generate_parameters_1.GenerateParameters(operation, project, components);
29
- yield generate_request_body_1.GenerateRequestBody(operation, project, components);
30
- yield generate_response_1.GenerateResponse(operation, project, components);
31
- for (const generatorFunction of generatorFunctionList) {
32
- try {
33
- const parameters = Object.assign(Object.assign({}, operation), { components,
34
- method,
35
- path,
36
- project,
37
- options });
38
- yield generatorFunction(parameters);
39
- }
40
- catch (e) {
41
- console.error(`Failed to generate [${generatorFunction === null || generatorFunction === void 0 ? void 0 : generatorFunction.name}] for operation: ${operation.operationId}`);
42
- }
43
- }
44
- }
45
- else {
46
- console.warn('Ensure all operation have a operation id.');
47
- }
51
+ console.warn('Ensure all operation have a operation id.');
48
52
  }
49
53
  }
50
54
  }
51
55
  }
52
56
  }
53
- });
57
+ }
58
+ return Promise.all(promiseList);
54
59
  }
55
60
  exports.GenerateOperation = GenerateOperation;
56
61
  //# sourceMappingURL=generate-operation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-operation.js","sourceRoot":"","sources":["../../../../../libs/open-api/src/lib/generate-operation.ts"],"names":[],"mappings":";;;;AACA,+DAA0D;AAC1D,mEAA+D;AAC/D,yEAAoE;AAEpE,mCAKiB;AACjB,+DAA2D;AAC3D,mEAA8D;AAC9D,2DAAuD;AACvD,+DAA2D;AAE3D,SAAsB,iBAAiB,CACrC,OAA2B,EAC3B,OAAgB,EAChB,OAAgB,EAChB,qBAAmD;;;QAEnD,MAAM,UAAU,GAA+B,MAAA,MAAC,OAAe,CAAC,UAAU,mCAAK,OAAe,CAAC,WAAW,mCAAI,EAAE,CAAC;QAEjH,MAAM,wCAAkB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAE9C,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YAE3D,IAAI,OAAO,EAAE;gBAEX,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,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