@ama-sdk/schematics 8.3.0-alpha.38 → 8.4.0-alpha.18
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 +2 -2
- package/package.json +16 -9
- package/schematics/code-generator/code-generator.d.ts +70 -0
- package/schematics/code-generator/code-generator.d.ts.map +1 -0
- package/schematics/code-generator/code-generator.js +90 -0
- package/schematics/code-generator/open-api-cli-generator/open-api-cli.generator.d.ts +31 -0
- package/schematics/code-generator/open-api-cli-generator/open-api-cli.generator.d.ts.map +1 -0
- package/schematics/code-generator/open-api-cli-generator/open-api-cli.generator.js +86 -0
- package/schematics/code-generator/open-api-cli-generator/open-api-cli.options.d.ts +33 -0
- package/schematics/code-generator/open-api-cli-generator/open-api-cli.options.d.ts.map +1 -0
- package/schematics/code-generator/open-api-cli-generator/open-api-cli.options.js +16 -0
- package/schematics/code-generator/swagger-java-generator/swagger-java.generator.d.ts +17 -0
- package/schematics/code-generator/swagger-java-generator/swagger-java.generator.d.ts.map +1 -0
- package/schematics/code-generator/swagger-java-generator/swagger-java.generator.js +67 -0
- package/schematics/code-generator/swagger-java-generator/swagger-java.options.d.ts +36 -0
- package/schematics/code-generator/swagger-java-generator/swagger-java.options.d.ts.map +1 -0
- package/schematics/code-generator/swagger-java-generator/swagger-java.options.js +17 -0
- package/schematics/java/client-core/index.d.ts.map +1 -1
- package/schematics/java/client-core/index.js +14 -8
- package/schematics/java/client-core/schema.d.ts +1 -1
- package/schematics/java/client-core/schema.d.ts.map +1 -1
- package/schematics/java/client-core/schema.json +2 -2
- package/schematics/ng-add/index.js +1 -1
- package/schematics/typescript/core/index.d.ts.map +1 -1
- package/schematics/typescript/core/index.js +27 -12
- package/schematics/typescript/core/schema.d.ts +1 -1
- package/schematics/typescript/core/schema.d.ts.map +1 -1
- package/schematics/typescript/core/schema.json +4 -4
- package/schematics/typescript/create/schema.json +2 -2
- package/schematics/typescript/mock/index.js +2 -2
- package/schematics/typescript/shell/index.d.ts.map +1 -1
- package/schematics/typescript/shell/index.js +7 -2
- package/schematics/typescript/shell/templates/base/openapitools.json +7 -0
- package/schematics/typescript/shell/templates/base/package.json +3 -2
- package/schematics/typescript/shell/templates/base/readme.md +2 -2
- package/schematics/typescript/shell/templates/base/scripts/files-pack.js +7 -7
- package/schematics/typescript/shell/templates/base/scripts/override-readme.js +2 -2
- package/schematics/typescript/shell/templates/base/scripts/restore-readme.js +2 -2
- package/schematics/api-extension/index.js.map +0 -1
- package/schematics/api-extension/schema.js.map +0 -1
- package/schematics/helpers/execute-jars.d.ts +0 -14
- package/schematics/helpers/execute-jars.d.ts.map +0 -1
- package/schematics/helpers/execute-jars.js +0 -62
- package/schematics/helpers/execute-jars.js.map +0 -1
- package/schematics/helpers/generator-java.task.d.ts +0 -59
- package/schematics/helpers/generator-java.task.d.ts.map +0 -1
- package/schematics/helpers/generator-java.task.js +0 -83
- package/schematics/helpers/generator-java.task.js.map +0 -1
- package/schematics/helpers/read-package.js.map +0 -1
- package/schematics/helpers/tree-glob.js.map +0 -1
- package/schematics/java/client-core/index.js.map +0 -1
- package/schematics/java/client-core/schema.js.map +0 -1
- package/schematics/java/client-core/swagger-codegen-java-client/target/javaClient-swagger-codegen-tests.jar +0 -0
- package/schematics/java/client-core/swagger-codegen-java-client/target/javaClient-swagger-codegen.jar +0 -0
- package/schematics/ng-add/index.js.map +0 -1
- package/schematics/ng-add/schema.js.map +0 -1
- package/schematics/resources/swagger-codegen-cli.jar +0 -0
- package/schematics/typescript/core/index.js.map +0 -1
- package/schematics/typescript/core/schema.js.map +0 -1
- package/schematics/typescript/core/swagger-codegen-typescript/target/typescriptFetch-swagger-codegen-tests.jar +0 -0
- package/schematics/typescript/core/swagger-codegen-typescript/target/typescriptFetch-swagger-codegen.jar +0 -0
- package/schematics/typescript/create/index.js.map +0 -1
- package/schematics/typescript/create/schema.js.map +0 -1
- package/schematics/typescript/mock/index.js.map +0 -1
- package/schematics/typescript/mock/schema.js.map +0 -1
- package/schematics/typescript/shell/index.js.map +0 -1
- package/schematics/typescript/shell/schema.js.map +0 -1
- /package/schematics/typescript/shell/templates/base/{.swagger-codegen-ignore → .openapi-codegen-ignore} +0 -0
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ If you use `Yarn2+`, you can use the following `scripts` in `package.json`:
|
|
|
53
53
|
|
|
54
54
|
```json
|
|
55
55
|
"resolve": "node -e 'process.stdout.write(require.resolve(process.argv[1]));'",
|
|
56
|
-
"generate": "yarn schematics @ama-sdk/schematics:typescript-core --
|
|
56
|
+
"generate": "yarn schematics @ama-sdk/schematics:typescript-core --spec-path ./swagger-spec.yaml",
|
|
57
57
|
"upgrade:repository": "yarn schematics @ama-sdk/schematics:typescript-shell",
|
|
58
58
|
```
|
|
59
59
|
|
|
@@ -66,7 +66,7 @@ Generate a Java Client Core SDK:
|
|
|
66
66
|
Make sure to have a `./swagger-spec.yaml` file at the root of your project and run:
|
|
67
67
|
|
|
68
68
|
```shell
|
|
69
|
-
yarn schematics @ama-sdk/schematics:java-client-core --
|
|
69
|
+
yarn schematics @ama-sdk/schematics:java-client-core --spec-path ./swagger-spec.yaml --swagger-config-path ./swagger-codegen-config.json
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
[Default swagger config](./schematics/java/client-core/swagger-codegen-java-client/config/swagger-codegen-config.json) will be used if `--swagger-config-path` is not provided.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ama-sdk/schematics",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.0-alpha.18",
|
|
4
4
|
"description": "Swagger specification SDK Generator by schematics",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"nx": "nx",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"build": "yarn nx build ama-sdk-schematics",
|
|
11
11
|
"build:builders": "tsc -b tsconfig.builders.json --pretty",
|
|
12
12
|
"install-swagger-cli": "mvn install:install-file -DgroupId=io.swagger -DartifactId=swagger-codegen-cli -Dversion=2.4.0-AMADEUS -Dpackaging=jar -Dfile=./schematics/resources/swagger-codegen-cli.jar",
|
|
13
|
-
"build:swagger": "yarn install-swagger-cli && run-p 'build:swagger-*'",
|
|
14
|
-
"build:
|
|
13
|
+
"build:swagger": "yarn install-swagger-cli && run-p 'build:swagger-*' 'build:openapi-*'",
|
|
14
|
+
"build:openapi-typescript-gen": "mvn clean package -f ./schematics/typescript/core/openapi-codegen-typescript/pom.xml",
|
|
15
15
|
"build:swagger-java-client-gen": "mvn clean package -f ./schematics/java/client-core/swagger-codegen-java-client/pom.xml",
|
|
16
16
|
"prepare:publish": "prepare-publish ./dist"
|
|
17
17
|
},
|
|
@@ -32,33 +32,39 @@
|
|
|
32
32
|
},
|
|
33
33
|
"@angular/compiler": {
|
|
34
34
|
"optional": true
|
|
35
|
+
},
|
|
36
|
+
"@openapitools/openapi-generator-cli": {
|
|
37
|
+
"optional": true
|
|
35
38
|
}
|
|
36
39
|
},
|
|
37
40
|
"peerDependencies": {
|
|
38
|
-
"@ama-sdk/core": "^8.
|
|
41
|
+
"@ama-sdk/core": "^8.4.0-alpha.18",
|
|
39
42
|
"@angular-devkit/core": "~15.2.0",
|
|
40
43
|
"@angular-devkit/schematics": "~15.2.0",
|
|
41
44
|
"@angular-devkit/schematics-cli": "~15.2.0",
|
|
42
45
|
"@angular/cli": "~15.2.0",
|
|
46
|
+
"@openapitools/openapi-generator-cli": "~2.6.0",
|
|
43
47
|
"@schematics/angular": "~15.2.0"
|
|
44
48
|
},
|
|
45
49
|
"dependencies": {
|
|
46
50
|
"@angular-devkit/core": "~15.2.0",
|
|
47
51
|
"@angular-devkit/schematics": "~15.2.0",
|
|
48
|
-
"@o3r/dev-tools": "^8.
|
|
52
|
+
"@o3r/dev-tools": "^8.4.0-alpha.18",
|
|
49
53
|
"minimatch": "^6.1.6",
|
|
50
54
|
"rxjs": "^7.4.0",
|
|
55
|
+
"semver": "^7.5.2",
|
|
51
56
|
"sway": "^2.0.6",
|
|
52
57
|
"tslib": "^2.4.1"
|
|
53
58
|
},
|
|
54
59
|
"devDependencies": {
|
|
55
|
-
"@ama-sdk/core": "^8.
|
|
60
|
+
"@ama-sdk/core": "^8.4.0-alpha.18",
|
|
56
61
|
"@angular-devkit/schematics-cli": "~15.2.0",
|
|
57
62
|
"@angular-eslint/eslint-plugin": "~15.2.0",
|
|
58
63
|
"@angular/cli": "~15.2.0",
|
|
59
64
|
"@nrwl/jest": "~15.9.0",
|
|
60
|
-
"@o3r/build-helpers": "^8.
|
|
61
|
-
"@o3r/eslint-plugin": "^8.
|
|
65
|
+
"@o3r/build-helpers": "^8.4.0-alpha.18",
|
|
66
|
+
"@o3r/eslint-plugin": "^8.4.0-alpha.18",
|
|
67
|
+
"@openapitools/openapi-generator-cli": "~2.6.0",
|
|
62
68
|
"@schematics/angular": "~15.2.0",
|
|
63
69
|
"@types/jest": "~28.1.2",
|
|
64
70
|
"@types/minimatch": "^5.1.2",
|
|
@@ -82,11 +88,12 @@
|
|
|
82
88
|
"nx": "~15.9.0",
|
|
83
89
|
"onchange": "^7.0.2",
|
|
84
90
|
"pid-from-port": "^1.1.3",
|
|
85
|
-
"semver": "^7.
|
|
91
|
+
"semver": "^7.5.2",
|
|
86
92
|
"ts-jest": "^28.0.5",
|
|
87
93
|
"type-fest": "^3.6.1",
|
|
88
94
|
"typescript": "~4.9.4"
|
|
89
95
|
},
|
|
96
|
+
"openApiSupportedVersion": "~6.6.0",
|
|
90
97
|
"engines": {
|
|
91
98
|
"node": ">=16.0.0",
|
|
92
99
|
"npm": ">=4",
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { TaskExecutor } from '@angular-devkit/schematics';
|
|
2
|
+
/**
|
|
3
|
+
* Common configuration for all the code generators
|
|
4
|
+
*/
|
|
5
|
+
export type CodegenTaskOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* Path to the Swagger specification
|
|
8
|
+
*
|
|
9
|
+
* @default 'swagger-spec.yaml'
|
|
10
|
+
*/
|
|
11
|
+
specPath: string;
|
|
12
|
+
/**
|
|
13
|
+
* Path to the swagger configuration
|
|
14
|
+
*/
|
|
15
|
+
specConfigPath: string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Output path for the generated sdk
|
|
18
|
+
*/
|
|
19
|
+
outputPath: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Expose angular schematics to run any code generator.
|
|
23
|
+
* Handle the task registration, configuration and the schematic's schedule.
|
|
24
|
+
*
|
|
25
|
+
* As is, the CodeGenerator does not implement any actual code generation and needs to be extended to be functional
|
|
26
|
+
*
|
|
27
|
+
* @example {@link OpenApiCliGenerator}
|
|
28
|
+
*/
|
|
29
|
+
export declare class CodeGenerator<T extends CodegenTaskOptions> {
|
|
30
|
+
/**
|
|
31
|
+
* Refers to the name the {@link Task} will be identified in a {@link Rule} ${@link SchematicContext}
|
|
32
|
+
*/
|
|
33
|
+
protected generatorName: string;
|
|
34
|
+
/**
|
|
35
|
+
* Configure the code generation task
|
|
36
|
+
* Merge the generator's default options with the dynamic one provided by the schematics
|
|
37
|
+
*
|
|
38
|
+
* @param options to override the generator's {@link getDefaultOptions}
|
|
39
|
+
*/
|
|
40
|
+
private getTaskConfiguration;
|
|
41
|
+
/**
|
|
42
|
+
* Register the task in the rule's {@link SchematicContext}
|
|
43
|
+
*
|
|
44
|
+
* @param factoryOptions execution options (root directory for instance)
|
|
45
|
+
*/
|
|
46
|
+
private registerGeneratorExecutor;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the generator specific default options
|
|
49
|
+
*/
|
|
50
|
+
protected getDefaultOptions(): T;
|
|
51
|
+
/**
|
|
52
|
+
* Returns the schematic that will run the code generator
|
|
53
|
+
*
|
|
54
|
+
* @param _factoryOptions execution options (root directory for instance)
|
|
55
|
+
*/
|
|
56
|
+
protected runCodeGeneratorFactory(_factoryOptions?: {
|
|
57
|
+
rootDirectory?: string;
|
|
58
|
+
}): TaskExecutor<T>;
|
|
59
|
+
/**
|
|
60
|
+
* Returns the schematic to register, configure and run your code generator task
|
|
61
|
+
*
|
|
62
|
+
* @param generatorOptions to configure the generator and the specification file to use
|
|
63
|
+
* @param factoryOptions to configure the generator execution context
|
|
64
|
+
* @param factoryOptions.rootDirectory directory where all your commands will be run - fallback to process.cwd
|
|
65
|
+
*/
|
|
66
|
+
getGeneratorRunSchematic(generatorOptions: Partial<T>, factoryOptions?: {
|
|
67
|
+
rootDirectory?: string;
|
|
68
|
+
}): import("@angular-devkit/schematics").Rule;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=code-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-generator.d.ts","sourceRoot":"","sources":["../../../schematics/code-generator/code-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0E,YAAY,EAAQ,MAAM,4BAA4B,CAAC;AAGxI;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,aAAa,CAAC,CAAC,SAAS,kBAAkB;IACrD;;OAEG;IACH,SAAS,CAAC,aAAa,EAAE,MAAM,CAAM;IAErC;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAa5B;;;;OAIG;IACH,OAAO,CAAC,yBAAyB;IAcjC;;OAEG;IACH,SAAS,CAAC,iBAAiB,IAAI,CAAC;IAIhC;;;;OAIG;IACH,SAAS,CAAC,uBAAuB,CAAC,eAAe,GAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,YAAY,CAAC,CAAC,CAAC;IAMpG;;;;;;OAMG;IACI,wBAAwB,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,cAAc,GAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAO;CAU9G"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CodeGenerator = void 0;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
/**
|
|
6
|
+
* Expose angular schematics to run any code generator.
|
|
7
|
+
* Handle the task registration, configuration and the schematic's schedule.
|
|
8
|
+
*
|
|
9
|
+
* As is, the CodeGenerator does not implement any actual code generation and needs to be extended to be functional
|
|
10
|
+
*
|
|
11
|
+
* @example {@link OpenApiCliGenerator}
|
|
12
|
+
*/
|
|
13
|
+
class CodeGenerator {
|
|
14
|
+
constructor() {
|
|
15
|
+
/**
|
|
16
|
+
* Refers to the name the {@link Task} will be identified in a {@link Rule} ${@link SchematicContext}
|
|
17
|
+
*/
|
|
18
|
+
this.generatorName = '';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Configure the code generation task
|
|
22
|
+
* Merge the generator's default options with the dynamic one provided by the schematics
|
|
23
|
+
*
|
|
24
|
+
* @param options to override the generator's {@link getDefaultOptions}
|
|
25
|
+
*/
|
|
26
|
+
getTaskConfiguration(options) {
|
|
27
|
+
const name = this.generatorName;
|
|
28
|
+
const opts = { ...this.getDefaultOptions(), ...options };
|
|
29
|
+
return new (class {
|
|
30
|
+
toConfiguration() {
|
|
31
|
+
return {
|
|
32
|
+
name,
|
|
33
|
+
options: opts
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
})();
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Register the task in the rule's {@link SchematicContext}
|
|
40
|
+
*
|
|
41
|
+
* @param factoryOptions execution options (root directory for instance)
|
|
42
|
+
*/
|
|
43
|
+
registerGeneratorExecutor(factoryOptions) {
|
|
44
|
+
return (tree, context) => {
|
|
45
|
+
// workaround for issue https://github.com/angular/angular-cli/issues/12678
|
|
46
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
47
|
+
const host = context.engine._host;
|
|
48
|
+
host.registerTaskExecutor({
|
|
49
|
+
name: this.generatorName,
|
|
50
|
+
create: () => Promise.resolve(this.runCodeGeneratorFactory(factoryOptions))
|
|
51
|
+
});
|
|
52
|
+
return tree;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Returns the generator specific default options
|
|
57
|
+
*/
|
|
58
|
+
getDefaultOptions() {
|
|
59
|
+
throw new Error('No implementation, please target an implementation');
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns the schematic that will run the code generator
|
|
63
|
+
*
|
|
64
|
+
* @param _factoryOptions execution options (root directory for instance)
|
|
65
|
+
*/
|
|
66
|
+
runCodeGeneratorFactory(_factoryOptions = {}) {
|
|
67
|
+
return (_options) => {
|
|
68
|
+
return Promise.reject('No implementation, please target an implementation');
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Returns the schematic to register, configure and run your code generator task
|
|
73
|
+
*
|
|
74
|
+
* @param generatorOptions to configure the generator and the specification file to use
|
|
75
|
+
* @param factoryOptions to configure the generator execution context
|
|
76
|
+
* @param factoryOptions.rootDirectory directory where all your commands will be run - fallback to process.cwd
|
|
77
|
+
*/
|
|
78
|
+
getGeneratorRunSchematic(generatorOptions, factoryOptions = {}) {
|
|
79
|
+
const scheduleTask = (tree, context) => {
|
|
80
|
+
context.addTask(this.getTaskConfiguration(generatorOptions));
|
|
81
|
+
return tree;
|
|
82
|
+
};
|
|
83
|
+
return (0, schematics_1.chain)([
|
|
84
|
+
this.registerGeneratorExecutor(factoryOptions),
|
|
85
|
+
scheduleTask
|
|
86
|
+
]);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.CodeGenerator = CodeGenerator;
|
|
90
|
+
//# sourceMappingURL=code-generator.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CodeGenerator } from '../code-generator';
|
|
2
|
+
import { OpenApiCliOptions } from './open-api-cli.options';
|
|
3
|
+
/**
|
|
4
|
+
* Manage the schematic to generate a sdk using the @openapitools/openapi-generator-cli
|
|
5
|
+
*/
|
|
6
|
+
export declare class OpenApiCliGenerator extends CodeGenerator<OpenApiCliOptions> {
|
|
7
|
+
private packageManager;
|
|
8
|
+
/** @inheritDoc */
|
|
9
|
+
protected generatorName: string;
|
|
10
|
+
/**
|
|
11
|
+
* Install the specified java open api generator
|
|
12
|
+
*
|
|
13
|
+
* @param version of the OpenApi Generator jar to use
|
|
14
|
+
* @param spawnOptions to configure your command line environment
|
|
15
|
+
*/
|
|
16
|
+
private runInstallOpenApiGenerator;
|
|
17
|
+
/**
|
|
18
|
+
* Run the OpenApi generator jar with the configuration specified to generate a SDK based on the specified specification
|
|
19
|
+
*
|
|
20
|
+
* @param generatorOptions contains the version of the generator to use, the output dir, the specification file and config to use etc.
|
|
21
|
+
* @param spawnOptions to configure your command line environment
|
|
22
|
+
*/
|
|
23
|
+
private runGenerator;
|
|
24
|
+
/** @inheritDoc */
|
|
25
|
+
protected getDefaultOptions: () => OpenApiCliOptions;
|
|
26
|
+
/** @inheritDoc */
|
|
27
|
+
protected runCodeGeneratorFactory: (factoryOptions?: {
|
|
28
|
+
rootDirectory?: string;
|
|
29
|
+
}) => (generatorOptions?: OpenApiCliOptions) => Promise<undefined>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=open-api-cli.generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-api-cli.generator.d.ts","sourceRoot":"","sources":["../../../../schematics/code-generator/open-api-cli-generator/open-api-cli.generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAoC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AAE5F;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,aAAa,CAAC,iBAAiB,CAAC;IACvE,OAAO,CAAC,cAAc,CAA+G;IACrI,kBAAkB;IAClB,SAAS,CAAC,aAAa,SAA6B;IAEpD;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;IAelC;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAuBpB,kBAAkB;IAClB,SAAS,CAAC,iBAAiB,0BAA2C;IAEtE,kBAAkB;IAClB,SAAS,CAAC,uBAAuB,oBAAoB;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,yBAE5C,iBAAiB,wBAclD;CACH"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpenApiCliGenerator = void 0;
|
|
4
|
+
const code_generator_1 = require("../code-generator");
|
|
5
|
+
const node_child_process_1 = require("node:child_process");
|
|
6
|
+
const open_api_cli_options_1 = require("./open-api-cli.options");
|
|
7
|
+
/**
|
|
8
|
+
* Manage the schematic to generate a sdk using the @openapitools/openapi-generator-cli
|
|
9
|
+
*/
|
|
10
|
+
class OpenApiCliGenerator extends code_generator_1.CodeGenerator {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.packageManager = process.env && process.env.npm_execpath && process.env.npm_execpath.indexOf('yarn') === -1 ? 'npm' : 'yarn';
|
|
14
|
+
/** @inheritDoc */
|
|
15
|
+
this.generatorName = 'openapi-codegen-npm-cli';
|
|
16
|
+
/** @inheritDoc */
|
|
17
|
+
this.getDefaultOptions = () => open_api_cli_options_1.defaultTypescriptGeneratorOptions;
|
|
18
|
+
/** @inheritDoc */
|
|
19
|
+
this.runCodeGeneratorFactory = (factoryOptions = {}) => {
|
|
20
|
+
const rootDirectory = factoryOptions.rootDirectory || process.cwd();
|
|
21
|
+
return async (generatorOptions) => {
|
|
22
|
+
if (!generatorOptions) {
|
|
23
|
+
return Promise.reject('Missing options to run open api generator');
|
|
24
|
+
}
|
|
25
|
+
const spawnOptions = {
|
|
26
|
+
stdio: 'inherit',
|
|
27
|
+
shell: true,
|
|
28
|
+
cwd: rootDirectory
|
|
29
|
+
};
|
|
30
|
+
if (generatorOptions.generatorVersion) {
|
|
31
|
+
await this.runInstallOpenApiGenerator(generatorOptions.generatorVersion, spawnOptions);
|
|
32
|
+
}
|
|
33
|
+
await this.runGenerator(generatorOptions, spawnOptions);
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Install the specified java open api generator
|
|
39
|
+
*
|
|
40
|
+
* @param version of the OpenApi Generator jar to use
|
|
41
|
+
* @param spawnOptions to configure your command line environment
|
|
42
|
+
*/
|
|
43
|
+
runInstallOpenApiGenerator(version, spawnOptions) {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
(0, node_child_process_1.spawn)(this.packageManager, ['run', 'openapi-generator-cli', 'version-manager', 'set', version], spawnOptions).on('close', (code) => {
|
|
46
|
+
if (code === 0) {
|
|
47
|
+
resolve();
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
reject(new Error(`OpenApiGeneratorCli failed to install OpenApiGenerator@${version}`));
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Run the OpenApi generator jar with the configuration specified to generate a SDK based on the specified specification
|
|
57
|
+
*
|
|
58
|
+
* @param generatorOptions contains the version of the generator to use, the output dir, the specification file and config to use etc.
|
|
59
|
+
* @param spawnOptions to configure your command line environment
|
|
60
|
+
*/
|
|
61
|
+
runGenerator(generatorOptions, spawnOptions) {
|
|
62
|
+
const args = [
|
|
63
|
+
'run',
|
|
64
|
+
'openapi-generator-cli',
|
|
65
|
+
'generate',
|
|
66
|
+
generatorOptions.generatorCustomPath ? `--custom-generator=${generatorOptions.generatorCustomPath}` : '',
|
|
67
|
+
'-g', generatorOptions.generatorName,
|
|
68
|
+
'-i', generatorOptions.specPath,
|
|
69
|
+
...generatorOptions.specConfigPath ? ['-c', generatorOptions.specConfigPath] : [],
|
|
70
|
+
'-o', generatorOptions.outputPath
|
|
71
|
+
];
|
|
72
|
+
return new Promise((resolve, reject) => {
|
|
73
|
+
(0, node_child_process_1.spawn)(this.packageManager === 'npm' ? 'npx' : this.packageManager, args, spawnOptions)
|
|
74
|
+
.on('close', (code) => {
|
|
75
|
+
if (code === 0) {
|
|
76
|
+
resolve();
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
reject(new Error(`OpenApiGeneratorCli failed to run OpenApiGenerator with command '${args.join(' ')}'`));
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.OpenApiCliGenerator = OpenApiCliGenerator;
|
|
86
|
+
//# sourceMappingURL=open-api-cli.generator.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { CodegenTaskOptions } from '../code-generator';
|
|
2
|
+
/**
|
|
3
|
+
* Options to pass the {@link OpenApiCliGenerator} to configure the generator
|
|
4
|
+
* and to specify the spec to generate
|
|
5
|
+
*/
|
|
6
|
+
export type OpenApiCliOptions = CodegenTaskOptions & {
|
|
7
|
+
/**
|
|
8
|
+
* The version of the Open Api Generator jar that will be downloaded and used to generate your sdk
|
|
9
|
+
* If null, it will use the one already defined in your project:
|
|
10
|
+
* - the one defined in your openapitools.json
|
|
11
|
+
* - the latest version if openapitools.json is missing
|
|
12
|
+
*
|
|
13
|
+
* @default null
|
|
14
|
+
*/
|
|
15
|
+
generatorVersion: string | null;
|
|
16
|
+
/**
|
|
17
|
+
* The Open Api Generator to run
|
|
18
|
+
*
|
|
19
|
+
* @default 'typescriptFetch' - our own typescript custom generator
|
|
20
|
+
*/
|
|
21
|
+
generatorName: string;
|
|
22
|
+
/**
|
|
23
|
+
* Path to a custom generator
|
|
24
|
+
*
|
|
25
|
+
* @default path to our own custom typescript generator
|
|
26
|
+
*/
|
|
27
|
+
generatorCustomPath: string | null;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Default options to run our custom typescript generator
|
|
31
|
+
*/
|
|
32
|
+
export declare const defaultTypescriptGeneratorOptions: OpenApiCliOptions;
|
|
33
|
+
//# sourceMappingURL=open-api-cli.options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-api-cli.options.d.ts","sourceRoot":"","sources":["../../../../schematics/code-generator/open-api-cli-generator/open-api-cli.options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAGrD;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,GAAG;IACnD;;;;;;;OAOG;IACH,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC;;;;OAIG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iCAAiC,EAAE,iBAO/C,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultTypescriptGeneratorOptions = void 0;
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
/**
|
|
6
|
+
* Default options to run our custom typescript generator
|
|
7
|
+
*/
|
|
8
|
+
exports.defaultTypescriptGeneratorOptions = {
|
|
9
|
+
generatorVersion: null,
|
|
10
|
+
generatorName: 'typescriptFetch',
|
|
11
|
+
generatorCustomPath: path.join(__dirname, '..', '..', 'typescript', 'core', 'openapi-codegen-typescript', 'target', 'typescriptFetch-openapi-generator.jar'),
|
|
12
|
+
specPath: 'swagger-spec.yaml',
|
|
13
|
+
outputPath: '.',
|
|
14
|
+
specConfigPath: null
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=open-api-cli.options.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CodeGenerator } from '../code-generator';
|
|
2
|
+
import { JavaGeneratorTaskOptions } from './swagger-java.options';
|
|
3
|
+
/**
|
|
4
|
+
* Manage the schematic to generate a sdk using the Swagger 2 Generator
|
|
5
|
+
* Note: a working java setup compatible with Swagger 2 Generator is required to use this class
|
|
6
|
+
*/
|
|
7
|
+
export declare class SwaggerJavaGenerator extends CodeGenerator<JavaGeneratorTaskOptions> {
|
|
8
|
+
/** @inheritDoc */
|
|
9
|
+
protected generatorName: string;
|
|
10
|
+
/** @inheritDoc */
|
|
11
|
+
protected getDefaultOptions: () => JavaGeneratorTaskOptions;
|
|
12
|
+
/** @inheritDoc */
|
|
13
|
+
protected runCodeGeneratorFactory(factoryOptions?: {
|
|
14
|
+
rootDirectory?: string;
|
|
15
|
+
}): (generatorOptions?: JavaGeneratorTaskOptions) => Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=swagger-java.generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swagger-java.generator.d.ts","sourceRoot":"","sources":["../../../../schematics/code-generator/swagger-java-generator/swagger-java.generator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAkB,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAElF;;;GAGG;AACH,qBAAa,oBAAqB,SAAQ,aAAa,CAAC,wBAAwB,CAAC;IAC/E,kBAAkB;IAClB,SAAS,CAAC,aAAa,SAAoB;IAE3C,kBAAkB;IAClB,SAAS,CAAC,iBAAiB,iCAAwB;IACnD,kBAAkB;IAClB,SAAS,CAAC,uBAAuB,CAAC,cAAc,GAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAO,uBAE9C,wBAAwB;CA6C5D"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SwaggerJavaGenerator = void 0;
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
const node_child_process_1 = require("node:child_process");
|
|
6
|
+
const code_generator_1 = require("../code-generator");
|
|
7
|
+
const swagger_java_options_1 = require("./swagger-java.options");
|
|
8
|
+
/**
|
|
9
|
+
* Manage the schematic to generate a sdk using the Swagger 2 Generator
|
|
10
|
+
* Note: a working java setup compatible with Swagger 2 Generator is required to use this class
|
|
11
|
+
*/
|
|
12
|
+
class SwaggerJavaGenerator extends code_generator_1.CodeGenerator {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
/** @inheritDoc */
|
|
16
|
+
this.generatorName = 'java-generator';
|
|
17
|
+
/** @inheritDoc */
|
|
18
|
+
this.getDefaultOptions = () => swagger_java_options_1.defaultOptions;
|
|
19
|
+
}
|
|
20
|
+
/** @inheritDoc */
|
|
21
|
+
runCodeGeneratorFactory(factoryOptions = {}) {
|
|
22
|
+
const rootDirectory = factoryOptions.rootDirectory || process.cwd();
|
|
23
|
+
return async (generatorOptions) => {
|
|
24
|
+
if (!generatorOptions) {
|
|
25
|
+
return Promise.reject('Missing options');
|
|
26
|
+
}
|
|
27
|
+
const spawnOptions = {
|
|
28
|
+
stdio: 'inherit',
|
|
29
|
+
shell: true,
|
|
30
|
+
cwd: rootDirectory
|
|
31
|
+
};
|
|
32
|
+
const codegenPath = path.join(generatorOptions.targetFolder, `${generatorOptions.codegenLanguage}-${generatorOptions.codegenFileName}`);
|
|
33
|
+
const cliPath = path.resolve(__dirname, '..', '..', 'resources', generatorOptions.cliFilename);
|
|
34
|
+
const args = [
|
|
35
|
+
'-cp',
|
|
36
|
+
codegenPath + path.delimiter + cliPath,
|
|
37
|
+
'io.swagger.codegen.SwaggerCodegen',
|
|
38
|
+
'generate',
|
|
39
|
+
'-l',
|
|
40
|
+
generatorOptions.codegenLanguage,
|
|
41
|
+
'-i',
|
|
42
|
+
generatorOptions.specPath,
|
|
43
|
+
'-o',
|
|
44
|
+
generatorOptions.outputPath
|
|
45
|
+
];
|
|
46
|
+
if (!generatorOptions.apiTests) {
|
|
47
|
+
args.push('-DapiTests=false');
|
|
48
|
+
}
|
|
49
|
+
if (generatorOptions.specConfigPath) {
|
|
50
|
+
args.push(`-c=${generatorOptions.specConfigPath}`);
|
|
51
|
+
}
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
(0, node_child_process_1.spawn)('java', args, spawnOptions)
|
|
54
|
+
.on('close', (code) => {
|
|
55
|
+
if (code === 0) {
|
|
56
|
+
resolve();
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
reject(new Error(`Java generator failed with status ${code}`));
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.SwaggerJavaGenerator = SwaggerJavaGenerator;
|
|
67
|
+
//# sourceMappingURL=swagger-java.generator.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CodegenTaskOptions } from '../code-generator';
|
|
2
|
+
/**
|
|
3
|
+
* Options for the generator-java task.
|
|
4
|
+
*/
|
|
5
|
+
export type JavaGeneratorTaskOptions = CodegenTaskOptions & {
|
|
6
|
+
targetFolder: string;
|
|
7
|
+
/**
|
|
8
|
+
* Enable API testing in Swagger Codegen
|
|
9
|
+
*
|
|
10
|
+
* @default true
|
|
11
|
+
*/
|
|
12
|
+
apiTests: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Path to the Swagger CLI
|
|
15
|
+
*
|
|
16
|
+
* @default 'swagger-codegen-cli.jar'
|
|
17
|
+
*/
|
|
18
|
+
cliFilename: string;
|
|
19
|
+
/**
|
|
20
|
+
* Path to the Swagger Codegen
|
|
21
|
+
*
|
|
22
|
+
* @default 'swagger-codegen.jar'
|
|
23
|
+
*/
|
|
24
|
+
codegenFileName: string;
|
|
25
|
+
/**
|
|
26
|
+
* Template language use for the codegen
|
|
27
|
+
*
|
|
28
|
+
* @default 'default'
|
|
29
|
+
*/
|
|
30
|
+
codegenLanguage: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Default options to generate a JAVA sdk using the Swagger 2 Generator
|
|
34
|
+
*/
|
|
35
|
+
export declare const defaultOptions: JavaGeneratorTaskOptions;
|
|
36
|
+
//# sourceMappingURL=swagger-java.options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swagger-java.options.d.ts","sourceRoot":"","sources":["../../../../schematics/code-generator/swagger-java-generator/swagger-java.options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,kBAAkB,GAAG;IAC1D,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,wBAS5B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultOptions = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Default options to generate a JAVA sdk using the Swagger 2 Generator
|
|
6
|
+
*/
|
|
7
|
+
exports.defaultOptions = {
|
|
8
|
+
apiTests: true,
|
|
9
|
+
targetFolder: './',
|
|
10
|
+
cliFilename: 'swagger-codegen-cli.jar',
|
|
11
|
+
codegenFileName: 'swagger-codegen.jar',
|
|
12
|
+
codegenLanguage: 'default',
|
|
13
|
+
specPath: 'swagger-spec.yaml',
|
|
14
|
+
outputPath: '.',
|
|
15
|
+
specConfigPath: null
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=swagger-java.options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/java/client-core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,IAAI,EAEC,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/java/client-core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,IAAI,EAEC,MAAM,4BAA4B,CAAC;AAI1C,OAAO,EAAE,wCAAwC,EAAE,MAAM,UAAU,CAAC;AAMpE;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,wCAAwC,GAAG,IAAI,CAqEhG"}
|