@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 +22 -0
- package/package.json +1 -1
- package/src/lib/generate-components.d.ts +1 -1
- package/src/lib/generate-components.js +17 -12
- package/src/lib/generate-components.js.map +1 -1
- package/src/lib/generate-operation.d.ts +2 -2
- package/src/lib/generate-operation.js +42 -37
- package/src/lib/generate-operation.js.map +1 -1
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,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
|
|
7
|
+
function executeInterfaceBuild(components, project, schema, name) {
|
|
8
8
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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":";;;;
|
|
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 {
|
|
4
|
-
export declare function GenerateOperation<Options extends OpenApiSchemaBase = OpenApiSchemaBase>(openapi: OpenAPIV3.Document, project: Project, options: Options, generatorFunctionList: GeneratorFunction<Options>[]): Promise<
|
|
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
|
|
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
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
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":";;;;
|
|
1
|
+
{"version":3,"file":"generate-operation.js","sourceRoot":"","sources":["../../../../../libs/open-api/src/lib/generate-operation.ts"],"names":[],"mappings":";;;;AAEA,+DAA2D;AAC3D,+DAA2D;AAC3D,mEAA8D;AAC9D,2DAAuD;AACvD,mCAAmH;AACnH,mEAA+D;AAC/D,+DAA0D;AAC1D,yEAAoE;AAEpE,SAAe,gBAAgB,CAC7B,OAAgB,EAChB,OAAgB,EAChB,IAAY,EACZ,MAAc,EACd,iBAA6C,EAC7C,UAAsC,EACtC,SAA0B;;QAE1B,IAAI;YACF,MAAM,UAAU,mCACX,SAAS,KACZ,UAAU;gBACV,MAAM;gBACN,IAAI;gBACJ,OAAO;gBACP,OAAO,GACR,CAAC;YACF,MAAM,iBAAiB,CAAC,UAAU,CAAC,CAAC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