@ama-sdk/schematics 9.1.0-alpha.3 → 9.1.0-alpha.30

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.
Files changed (28) hide show
  1. package/README.md +16 -0
  2. package/package.json +13 -16
  3. package/schematics/api-extension/schema.d.ts +2 -2
  4. package/schematics/api-extension/schema.d.ts.map +1 -1
  5. package/schematics/code-generator/open-api-cli-generator/open-api-cli.generator.d.ts.map +1 -1
  6. package/schematics/code-generator/open-api-cli-generator/open-api-cli.generator.js +2 -1
  7. package/schematics/code-generator/open-api-cli-generator/open-api-cli.options.d.ts +10 -1
  8. package/schematics/code-generator/open-api-cli-generator/open-api-cli.options.d.ts.map +1 -1
  9. package/schematics/code-generator/open-api-cli-generator/open-api-cli.options.js +2 -1
  10. package/schematics/java/client-core/schema.d.ts +3 -3
  11. package/schematics/java/client-core/schema.d.ts.map +1 -1
  12. package/schematics/java/client-core/swagger-codegen-java-client/target/javaClient-swagger-codegen-tests.jar +0 -0
  13. package/schematics/java/client-core/swagger-codegen-java-client/target/javaClient-swagger-codegen.jar +0 -0
  14. package/schematics/ng-add/schema.d.ts +3 -3
  15. package/schematics/ng-add/schema.d.ts.map +1 -1
  16. package/schematics/typescript/core/index.d.ts.map +1 -1
  17. package/schematics/typescript/core/index.js +2 -1
  18. package/schematics/typescript/core/openapi-codegen-typescript/target/typescriptFetch-openapi-generator-tests.jar +0 -0
  19. package/schematics/typescript/core/openapi-codegen-typescript/target/typescriptFetch-openapi-generator.jar +0 -0
  20. package/schematics/typescript/core/schema.d.ts +13 -5
  21. package/schematics/typescript/core/schema.d.ts.map +1 -1
  22. package/schematics/typescript/core/schema.json +5 -3
  23. package/schematics/typescript/mock/schema.d.ts +2 -2
  24. package/schematics/typescript/mock/schema.d.ts.map +1 -1
  25. package/schematics/typescript/shell/schema.d.ts +4 -4
  26. package/schematics/typescript/shell/schema.d.ts.map +1 -1
  27. package/schematics/typescript/shell/templates/base/package.json.template +1 -1
  28. package/schematics/typescript/shell/templates/base/readme.md +87 -3
package/README.md CHANGED
@@ -75,3 +75,19 @@ yarn schematics @ama-sdk/schematics:java-client-core --spec-path ./swagger-spec.
75
75
  ```
76
76
 
77
77
  [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.
78
+
79
+ ### Debug the typescript generator
80
+ The OpenApi generator extracts an enhanced JSON data model from the specification YAML and uses this data model to feed the templates to generate the code.
81
+ If there is an issue with the files generated with the spec provided, the generator provides debugging features that log this data model.
82
+
83
+ You can use global property options to pass one or both of the following options:
84
+ * debugModel - logs the full JSON structure used to generate models
85
+ * debugOperations - logs the full JSON structure used to generate operations
86
+
87
+ Example:
88
+ ```shell
89
+ yarn schematics @ama-sdk/schematics:typescript-core --spec-path ./swagger-spec.yaml --global-property debugModels,debugOperations
90
+ ```
91
+ You can also use npx instead of yarn in the command.
92
+
93
+ You can correlate this data model with the [templates](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/schematics/schematics/typescript/core/openapi-codegen-typescript/src/main/resources/typescriptFetch) used by the generator.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ama-sdk/schematics",
3
- "version": "9.1.0-alpha.3",
3
+ "version": "9.1.0-alpha.30",
4
4
  "description": "Swagger specification SDK Generator by schematics",
5
5
  "scripts": {
6
6
  "nx": "nx",
@@ -8,7 +8,7 @@
8
8
  "test": "yarn nx test ama-sdk-schematics",
9
9
  "prepare:build:builders": "yarn cpy 'schematics/**/*.json' 'schematics/**/templates/**' 'schematics/**/*.jar' dist/schematics && yarn cpy '{package,collection}.json' dist",
10
10
  "build": "yarn nx build ama-sdk-schematics",
11
- "build:builders": "tsc -b tsconfig.builders.json --pretty",
11
+ "build:builders": "tsc -b tsconfig.builders.json --pretty && yarn generate-cjs-manifest",
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
13
  "build:swagger": "yarn install-swagger-cli && run-p 'build:swagger-*' 'build:openapi-*'",
14
14
  "build:openapi-typescript-gen": "mvn clean package -f ./schematics/typescript/core/openapi-codegen-typescript/pom.xml",
@@ -27,9 +27,6 @@
27
27
  "@angular-devkit/schematics-cli": {
28
28
  "optional": true
29
29
  },
30
- "@angular/cli": {
31
- "optional": true
32
- },
33
30
  "@angular/compiler": {
34
31
  "optional": true
35
32
  },
@@ -41,18 +38,17 @@
41
38
  }
42
39
  },
43
40
  "peerDependencies": {
44
- "@ama-sdk/core": "^9.1.0-alpha.3",
45
- "@angular-devkit/core": "~16.0.5",
46
- "@angular-devkit/schematics": "~16.0.5",
47
- "@angular-devkit/schematics-cli": "~16.0.5",
48
- "@angular/cli": "~16.0.5",
41
+ "@ama-sdk/core": "^9.1.0-alpha.30",
42
+ "@angular-devkit/core": "^16.0.5",
43
+ "@angular-devkit/schematics": "^16.0.5",
44
+ "@angular-devkit/schematics-cli": "^16.0.5",
49
45
  "@openapitools/openapi-generator-cli": "~2.7.0",
50
- "@schematics/angular": "~16.0.5"
46
+ "@schematics/angular": "^16.0.5"
51
47
  },
52
48
  "dependencies": {
53
49
  "@angular-devkit/core": "~16.0.5",
54
50
  "@angular-devkit/schematics": "~16.0.5",
55
- "@o3r/dev-tools": "^9.1.0-alpha.3",
51
+ "@o3r/dev-tools": "^9.1.0-alpha.30",
56
52
  "js-yaml": "^4.1.0",
57
53
  "minimatch": "^9.0.0",
58
54
  "rxjs": "^7.8.1",
@@ -61,14 +57,14 @@
61
57
  "tslib": "^2.5.3"
62
58
  },
63
59
  "devDependencies": {
64
- "@ama-sdk/core": "^9.1.0-alpha.3",
60
+ "@ama-sdk/core": "^9.1.0-alpha.30",
65
61
  "@angular-devkit/schematics-cli": "~16.0.5",
66
62
  "@angular-eslint/eslint-plugin": "~16.0.3",
67
63
  "@angular/cli": "~16.0.5",
68
64
  "@nx/jest": "~16.5.0",
69
- "@o3r/build-helpers": "^9.1.0-alpha.3",
70
- "@o3r/eslint-plugin": "^9.1.0-alpha.3",
71
- "@o3r/schematics": "^9.1.0-alpha.3",
65
+ "@o3r/build-helpers": "^9.1.0-alpha.30",
66
+ "@o3r/eslint-plugin": "^9.1.0-alpha.30",
67
+ "@o3r/schematics": "^9.1.0-alpha.30",
72
68
  "@openapitools/openapi-generator-cli": "~2.7.0",
73
69
  "@schematics/angular": "~16.0.5",
74
70
  "@types/jest": "~29.5.2",
@@ -89,6 +85,7 @@
89
85
  "eslint-plugin-unicorn": "^47.0.0",
90
86
  "isomorphic-fetch": "~3.0.0",
91
87
  "jest": "~29.6.0",
88
+ "jest-junit": "^16.0.0",
92
89
  "mem-fs": "^2.2.1",
93
90
  "npm-run-all": "^4.1.5",
94
91
  "nx": "~16.5.0",
@@ -1,5 +1,5 @@
1
- import { JsonObject } from '@angular-devkit/core';
2
- export interface NgGenerateApiExtensionSchematicsSchema extends JsonObject {
1
+ import type { SchematicOptionObject } from '@o3r/schematics';
2
+ export interface NgGenerateApiExtensionSchematicsSchema extends SchematicOptionObject {
3
3
  /** Extension Name */
4
4
  name: string;
5
5
  /** Type of the core API to extend */
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../schematics/api-extension/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,WAAW,sCAAuC,SAAQ,UAAU;IACxE,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,QAAQ,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC/B,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC;CACrB"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../schematics/api-extension/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,MAAM,WAAW,sCAAuC,SAAQ,qBAAqB;IACnF,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,QAAQ,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC/B,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC;CACrB"}
@@ -1 +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;AAI5F;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,aAAa,CAAC,iBAAiB,CAAC;IAEvE,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,KAAK,GAAG,MAAM,CAAC;IAClD,SAAS,KAAK,oBAAoB,IAAI,KAAK,GAAG,MAAM,CAEnD;IAED,kBAAkB;IAClB,SAAS,CAAC,QAAQ,CAAC,aAAa,6BAA6B;gBAEjD,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,EAAE,CAAA;KAAE;IAK9D;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;IAelC;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAsBpB,kBAAkB;IAClB,SAAS,CAAC,iBAAiB,0BAA2C;IAEtE,kBAAkB;IAClB,SAAS,CAAC,uBAAuB,oBAAoB;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,yBAI5C,iBAAiB,wBAclD;CACH"}
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;AAI5F;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,aAAa,CAAC,iBAAiB,CAAC;IAEvE,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,KAAK,GAAG,MAAM,CAAC;IAClD,SAAS,KAAK,oBAAoB,IAAI,KAAK,GAAG,MAAM,CAEnD;IAED,kBAAkB;IAClB,SAAS,CAAC,QAAQ,CAAC,aAAa,6BAA6B;gBAEjD,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,EAAE,CAAA;KAAE;IAK9D;;;;;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,yBAI5C,iBAAiB,wBAclD;CACH"}
@@ -73,7 +73,8 @@ class OpenApiCliGenerator extends code_generator_1.CodeGenerator {
73
73
  '-g', generatorOptions.generatorName,
74
74
  '-i', generatorOptions.specPath,
75
75
  ...generatorOptions.specConfigPath ? ['-c', generatorOptions.specConfigPath] : [],
76
- '-o', generatorOptions.outputPath
76
+ '-o', generatorOptions.outputPath,
77
+ ...generatorOptions.globalProperty ? ['--global-property', generatorOptions.globalProperty] : []
77
78
  ];
78
79
  return new Promise((resolve, reject) => {
79
80
  (0, node_child_process_1.spawn)(this.packageManagerRunner, args, spawnOptions)
@@ -10,7 +10,7 @@ export type OpenApiCliOptions = CodegenTaskOptions & {
10
10
  * - the one defined in your openapitools.json
11
11
  * - the latest version if openapitools.json is missing
12
12
  *
13
- * @default null
13
+ * @default ''
14
14
  */
15
15
  generatorVersion: string;
16
16
  /**
@@ -25,6 +25,15 @@ export type OpenApiCliOptions = CodegenTaskOptions & {
25
25
  * @default path to our own custom typescript generator
26
26
  */
27
27
  generatorCustomPath: string;
28
+ /**
29
+ * Comma separated string of options to give to the openapi-generator-cli
30
+ *
31
+ * @example debugModels to log the full json structure used to generate models
32
+ * @example debugOperations to log the full json structure used to generate operations
33
+ *
34
+ * @default ''
35
+ */
36
+ globalProperty: string;
28
37
  };
29
38
  /**
30
39
  * Default options to run our custom typescript generator
@@ -1 +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,CAAC;IACzB;;;;OAIG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iCAAiC,EAAE,iBAO/C,CAAC"}
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,CAAC;IACzB;;;;OAIG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;;;;;OAOG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iCAAiC,EAAE,iBAQ/C,CAAC"}
@@ -11,6 +11,7 @@ exports.defaultTypescriptGeneratorOptions = {
11
11
  generatorCustomPath: path.join(__dirname, '..', '..', 'typescript', 'core', 'openapi-codegen-typescript', 'target', 'typescriptFetch-openapi-generator.jar'),
12
12
  specPath: 'swagger-spec.yaml',
13
13
  outputPath: '.',
14
- specConfigPath: ''
14
+ specConfigPath: '',
15
+ globalProperty: ''
15
16
  };
16
17
  //# sourceMappingURL=open-api-cli.options.js.map
@@ -1,8 +1,8 @@
1
- import { JsonObject } from '@angular-devkit/core';
2
- export interface NgGenerateJavaClientCoreSchematicsSchema extends JsonObject {
1
+ import type { SchematicOptionObject } from '@o3r/schematics';
2
+ export interface NgGenerateJavaClientCoreSchematicsSchema extends SchematicOptionObject {
3
3
  /** Path to the swagger specification used to generate the SDK */
4
4
  specPath: string;
5
5
  /** Swagger config file */
6
- specConfigPath: string | null;
6
+ specConfigPath: string | undefined;
7
7
  }
8
8
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../schematics/java/client-core/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,WAAW,wCAAyC,SAAQ,UAAU;IAC1E,iEAAiE;IACjE,QAAQ,EAAE,MAAM,CAAC;IAEjB,0BAA0B;IAC1B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../schematics/java/client-core/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,MAAM,WAAW,wCAAyC,SAAQ,qBAAqB;IACrF,iEAAiE;IACjE,QAAQ,EAAE,MAAM,CAAC;IAEjB,0BAA0B;IAC1B,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC"}
@@ -1,6 +1,6 @@
1
- import type { JsonObject } from '@angular-devkit/core';
2
- export interface NgAddSchematicsSchema extends JsonObject {
1
+ import type { SchematicOptionObject } from '@o3r/schematics';
2
+ export interface NgAddSchematicsSchema extends SchematicOptionObject {
3
3
  /** Project name */
4
- projectName: string | null;
4
+ projectName: string | undefined;
5
5
  }
6
6
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,WAAW,qBAAsB,SAAQ,UAAU;IACvD,mBAAmB;IACnB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,MAAM,WAAW,qBAAsB,SAAQ,qBAAqB;IAClE,mBAAmB;IACnB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/typescript/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,IAAI,EAKL,MAAM,4BAA4B,CAAC;AASpC,OAAO,EAAE,2CAA2C,EAAE,MAAM,UAAU,CAAC;AAgBvE;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,2CAA2C,GAAG,IAAI,CA+GlG"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/typescript/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,IAAI,EAKL,MAAM,4BAA4B,CAAC;AASpC,OAAO,EAAE,2CAA2C,EAAE,MAAM,UAAU,CAAC;AAgBvE;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,2CAA2C,GAAG,IAAI,CAgHlG"}
@@ -25,6 +25,7 @@ const getPathObjectTemplate = (pathObj) => {
25
25
  function ngGenerateTypescriptSDK(options) {
26
26
  const specPath = path.resolve(process.cwd(), options.specPath);
27
27
  const targetPath = options.directory || '/';
28
+ const globalProperty = options.globalProperty;
28
29
  const generateOperationFinder = async () => {
29
30
  const swayOptions = {
30
31
  definition: path.resolve(options.specPath)
@@ -100,7 +101,7 @@ function ngGenerateTypescriptSDK(options) {
100
101
  return () => tree;
101
102
  };
102
103
  const runGeneratorRule = (tree, context) => {
103
- const generatorOptions = { specPath };
104
+ const generatorOptions = { specPath, globalProperty };
104
105
  const packageJsonFile = JSON.parse(((0, node_fs_1.readFileSync)(path.join(__dirname, '..', '..', '..', 'package.json'))).toString());
105
106
  const packageOpenApiSupportedVersion = packageJsonFile.openApiSupportedVersion?.replace(/\^|~/, '');
106
107
  let openApiVersion = '';
@@ -1,12 +1,20 @@
1
- import type { JsonObject } from '@angular-devkit/core';
2
- export interface NgGenerateTypescriptSDKCoreSchematicsSchema extends JsonObject {
1
+ import type { SchematicOptionObject } from '@o3r/schematics';
2
+ export interface NgGenerateTypescriptSDKCoreSchematicsSchema extends SchematicOptionObject {
3
3
  /** Path to the swagger specification used to generate the SDK */
4
4
  specPath: string;
5
5
  /** Directory where to generate the SDK */
6
- directory: string | null;
6
+ directory: string | undefined;
7
7
  /** Package manager to be used in the generated SDK */
8
- packageManager: 'npm' | 'yarn' | '';
8
+ packageManager: 'npm' | 'yarn' | undefined;
9
9
  /** Path to the spec generation configuration */
10
- specConfigPath: string | null;
10
+ specConfigPath: string | undefined;
11
+ /**
12
+ * Comma separated string of options to give to the openapi-generator-cli
13
+ *
14
+ * @example debugModels to log the full json structure used to generate models
15
+ * @example debugOperations to log the full json structure used to generate operations
16
+ * @default ''
17
+ */
18
+ globalProperty: string | undefined;
11
19
  }
12
20
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../schematics/typescript/core/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,WAAW,2CAA4C,SAAQ,UAAU;IAC7E,iEAAiE;IACjE,QAAQ,EAAE,MAAM,CAAC;IAEjB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB,sDAAsD;IACtD,cAAc,EAAE,KAAK,GAAG,MAAM,GAAG,EAAE,CAAC;IAEpC,gDAAgD;IAChD,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../schematics/typescript/core/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,MAAM,WAAW,2CAA4C,SAAQ,qBAAqB;IACxF,iEAAiE;IACjE,QAAQ,EAAE,MAAM,CAAC;IAEjB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAE9B,sDAAsD;IACtD,cAAc,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;IAE3C,gDAAgD;IAChD,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IAEnC;;;;;;OAMG;IACH,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC"}
@@ -24,12 +24,14 @@
24
24
  "packageManager": {
25
25
  "type": "string",
26
26
  "enum": [
27
- "",
28
27
  "npm",
29
28
  "yarn"
30
29
  ],
31
- "description": "Package manager to be used in the generated SDK",
32
- "default": ""
30
+ "description": "Package manager to be used in the generated SDK"
31
+ },
32
+ "globalProperty": {
33
+ "type": "string",
34
+ "description": "Comma separated string of options to give to the openapi-generator-cli"
33
35
  }
34
36
  },
35
37
  "additionalProperties": true,
@@ -1,5 +1,5 @@
1
- import type { JsonObject } from '@angular-devkit/core';
2
- export interface NgGenerateMockSchematicsSchema extends JsonObject {
1
+ import type { SchematicOptionObject } from '@o3r/schematics';
2
+ export interface NgGenerateMockSchematicsSchema extends SchematicOptionObject {
3
3
  /** Name of the api model to generate */
4
4
  apiModel: string;
5
5
  /** True if the api model has a property id */
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../schematics/typescript/mock/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAErD,MAAM,WAAW,8BAA+B,SAAQ,UAAU;IAChE,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;IAEjB,8CAA8C;IAC9C,UAAU,EAAE,OAAO,CAAC;IAEpB,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IAEb,8BAA8B;IAC9B,WAAW,EAAE,MAAM,CAAC;CACrB"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../schematics/typescript/mock/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,MAAM,WAAW,8BAA+B,SAAQ,qBAAqB;IAC3E,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;IAEjB,8CAA8C;IAC9C,UAAU,EAAE,OAAO,CAAC;IAEpB,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IAEb,8BAA8B;IAC9B,WAAW,EAAE,MAAM,CAAC;CACrB"}
@@ -1,13 +1,13 @@
1
- import type { JsonObject } from '@angular-devkit/core';
2
- export interface NgGenerateTypescriptSDKShellSchematicsSchema extends JsonObject {
1
+ import type { SchematicOptionObject } from '@o3r/schematics';
2
+ export interface NgGenerateTypescriptSDKShellSchematicsSchema extends SchematicOptionObject {
3
3
  /** Project name (NPM package scope, package.json name will be @{projectName}/{packageName}) */
4
4
  name: string;
5
5
  /** Package name (package.json name will be @{projectName}/{packageName}) */
6
6
  package: string;
7
7
  /** Project description */
8
- description: string | null;
8
+ description: string | undefined;
9
9
  /** Directory where to generate the SDK */
10
- directory: string | null;
10
+ directory: string | undefined;
11
11
  /** Package manager to be used in the generated SDK */
12
12
  packageManager: 'npm' | 'yarn' | '';
13
13
  /** Skip NPM install */
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../schematics/typescript/shell/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,WAAW,4CAA6C,SAAQ,UAAU;IAC9E,+FAA+F;IAC/F,IAAI,EAAE,MAAM,CAAC;IAEb,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAC;IAEhB,0BAA0B;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAE3B,0CAA0C;IAC1C,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB,sDAAsD;IACtD,cAAc,EAAE,KAAK,GAAG,MAAM,GAAG,EAAE,CAAC;IAEpC,uBAAuB;IACvB,WAAW,EAAE,OAAO,CAAC;CACtB"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../schematics/typescript/shell/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,MAAM,WAAW,4CAA6C,SAAQ,qBAAqB;IACzF,+FAA+F;IAC/F,IAAI,EAAE,MAAM,CAAC;IAEb,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAC;IAEhB,0BAA0B;IAC1B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAEhC,0CAA0C;IAC1C,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAE9B,sDAAsD;IACtD,cAAc,EAAE,KAAK,GAAG,MAAM,GAAG,EAAE,CAAC;IAEpC,uBAAuB;IACvB,WAAW,EAAE,OAAO,CAAC;CACtB"}
@@ -100,7 +100,7 @@
100
100
  "jest-junit": "^16.0.0",
101
101
  "lint-staged": "^13.0.0",
102
102
  "minimist": "^1.2.6",
103
- "rimraf": "^5.0.0",
103
+ "rimraf": "^5.0.1",
104
104
  "standard-version": "^9.0.0",
105
105
  "ts-jest": "<%= versions['ts-jest'] %>",
106
106
  "typedoc": "~0.24.0",
@@ -109,11 +109,95 @@ You can build and run UT with:
109
109
  yarn test
110
110
  ```
111
111
 
112
- ## Vendor extensions
112
+ ## Manage dates
113
+
114
+ ### The timezone issue
115
+ Managing dates with timezones has always been a bit painful in front end applications.
116
+ Let's give a concrete example to understand the problem:
117
+ An API returns the date and hour of your flight in the timezone of the airport location. In our use case, let's say the departure airport is on GTM+7 : 2023-07-10T00:37:00.000+07:00.
118
+ The timezone sent is the one from the airport, here GMT+7. If you just use the Date(), the computer browser will convert this in its own timezone.
119
+ For example, if the user is in GMT+2 you will end up displaying the following: 2023-07-09T19:37:00.000+02:00.
120
+ This is not what you want. You want the exact date time of the flight at the airport timezone, not the one of your user's computer.
121
+ However, there might be cases where you might still need the timezone information.
122
+ For example, you want to be able to display that the flight is in X hours.
123
+ You will need to compute this information with the two timezones -- the airport's and the user's.
124
+
125
+ ### Solution proposed to remove the timezone: utils.DateTime
126
+ We have introduced the utils.Date object to replace the Date implementation and ignore the timezone.
127
+ As we need to get rid of the timezones more often than not, this will be our default behavior.
128
+ By default, the Date models are replaced with utils.Date.
129
+
130
+ When we need to keep the timezone information, we create a new field directly in the SDK.
131
+ As this field does not exist in the specification, it will not be part of the base model but of the core model instead.
132
+
133
+ Simple example:
134
+ ```yaml
135
+ Flight:
136
+ type: "object"
137
+ required:
138
+ - departureDateTime
139
+ properties:
140
+ departureDateTime:
141
+ type: string
142
+ format: date-time
143
+ ```
144
+ Base model generated
145
+ ```typescript
146
+ // flight.ts generated in base models
147
+ export interface Flight {
148
+ /** @see utils.DateTime */
149
+ departureDateTime: utils.DateTime;
150
+ }
151
+ ```
152
+ You need to create a core model to store the timezone information (src/models/core/flight.ts):
153
+ ```typescript
154
+ import type { IgnoreEnum } from '@ama-sdk/core';
155
+ import type { Flight } from '../../base/flight/flight';
156
+ export type FlightStopCoreIfy<T extends IgnoreEnum<Flight>> = T & {
157
+ /** Departure date time of the flight considering timezone */
158
+ departureDateTimeConsideringTimezone?: Date;
159
+ };
160
+ ```
161
+
162
+ And an associated reviver (src/models/core/flight.reviver.ts):
163
+ ```typescript
164
+ import type { Flight } from '../../base/flight/flight';
165
+ import type { reviveFlight } from '../../base/flight/flight.reviver';
166
+ import type { FlightCoreIfy } from './flight';
167
+
168
+ /**
169
+ * @param baseRevive
170
+ */
171
+ export function reviveFlightFactory<R extends typeof reviveFlight>(baseRevive: R) {
172
+ const reviver = <T extends Flight = Flight>(data: any, dictionaries?: any) => {
173
+ const originalData: any = {...data};
174
+ const revivedData = baseRevive<FlightCoreIfy<T>>(data, dictionaries);
175
+ if (!revivedData) {
176
+ return;
177
+ }
178
+ revivedData.departureDateTimeConsideringTimezone = originalData.departureDateTimeConsideringTimezone && new Date(originalData.departureDateTimeConsideringTimezone)
179
+ || originalData.departureDateTime && new Date(originalData.departureDateTime);
180
+ return revivedData;
181
+ };
182
+ return reviver;
183
+ }
184
+ ```
185
+
186
+ And export it here (src/models/core/flight/index.ts):
187
+ ```typescript
188
+ export * from './flight';
189
+ export * from './flight.reviver';
190
+ ```
191
+
192
+ And here (src/models/core/index.ts):
193
+ ```typescript
194
+ export * from './flight/index';
195
+ ```
113
196
 
114
- These are some of the available configurations using vendor extensions in the swagger spec
197
+ You can now use departureDateTimeConsideringTimezone to access the timezone information.
198
+ See [utils.Date](https://github.com/AmadeusITGroup/otter/blob/main/packages/%40ama-sdk/core/src/fwk/date.ts) for more information.
115
199
 
116
- ### Manage timezone in date
200
+ ### How to keep the timezone (prevent Date replacement with utils.Date)
117
201
 
118
202
  In order to add the timezone to your timestamp property you can add the x-date-timezone extension in your yaml, for example:
119
203