@ama-sdk/schematics 9.0.0-rc.1 → 9.0.0-rc.13

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 (23) hide show
  1. package/README.md +16 -0
  2. package/package.json +7 -7
  3. package/schematics/code-generator/open-api-cli-generator/open-api-cli.generator.d.ts.map +1 -1
  4. package/schematics/code-generator/open-api-cli-generator/open-api-cli.generator.js +2 -1
  5. package/schematics/code-generator/open-api-cli-generator/open-api-cli.options.d.ts +10 -1
  6. package/schematics/code-generator/open-api-cli-generator/open-api-cli.options.d.ts.map +1 -1
  7. package/schematics/code-generator/open-api-cli-generator/open-api-cli.options.js +2 -1
  8. package/schematics/helpers/node-install.d.ts +0 -3
  9. package/schematics/helpers/node-install.d.ts.map +1 -1
  10. package/schematics/helpers/node-install.js +0 -3
  11. package/schematics/java/client-core/swagger-codegen-java-client/target/javaClient-swagger-codegen-tests.jar +0 -0
  12. package/schematics/java/client-core/swagger-codegen-java-client/target/javaClient-swagger-codegen.jar +0 -0
  13. package/schematics/typescript/core/index.d.ts.map +1 -1
  14. package/schematics/typescript/core/index.js +2 -1
  15. package/schematics/typescript/core/openapi-codegen-typescript/target/typescriptFetch-openapi-generator-tests.jar +0 -0
  16. package/schematics/typescript/core/openapi-codegen-typescript/target/typescriptFetch-openapi-generator.jar +0 -0
  17. package/schematics/typescript/core/schema.d.ts +9 -0
  18. package/schematics/typescript/core/schema.d.ts.map +1 -1
  19. package/schematics/typescript/core/schema.json +5 -0
  20. package/schematics/typescript/shell/schema.d.ts +2 -2
  21. package/schematics/typescript/shell/schema.d.ts.map +1 -1
  22. package/schematics/typescript/shell/schema.json +4 -4
  23. 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.0.0-rc.1",
3
+ "version": "9.0.0-rc.13",
4
4
  "description": "Swagger specification SDK Generator by schematics",
5
5
  "scripts": {
6
6
  "nx": "nx",
@@ -41,7 +41,7 @@
41
41
  }
42
42
  },
43
43
  "peerDependencies": {
44
- "@ama-sdk/core": "^9.0.0-rc.1",
44
+ "@ama-sdk/core": "^9.0.0-rc.13",
45
45
  "@angular-devkit/core": "~16.0.5",
46
46
  "@angular-devkit/schematics": "~16.0.5",
47
47
  "@angular-devkit/schematics-cli": "~16.0.5",
@@ -52,7 +52,7 @@
52
52
  "dependencies": {
53
53
  "@angular-devkit/core": "~16.0.5",
54
54
  "@angular-devkit/schematics": "~16.0.5",
55
- "@o3r/dev-tools": "^9.0.0-rc.1",
55
+ "@o3r/dev-tools": "^9.0.0-rc.13",
56
56
  "js-yaml": "^4.1.0",
57
57
  "minimatch": "^9.0.0",
58
58
  "rxjs": "^7.8.1",
@@ -61,14 +61,14 @@
61
61
  "tslib": "^2.5.3"
62
62
  },
63
63
  "devDependencies": {
64
- "@ama-sdk/core": "^9.0.0-rc.1",
64
+ "@ama-sdk/core": "^9.0.0-rc.13",
65
65
  "@angular-devkit/schematics-cli": "~16.0.5",
66
66
  "@angular-eslint/eslint-plugin": "~16.0.3",
67
67
  "@angular/cli": "~16.0.5",
68
68
  "@nx/jest": "~16.5.0",
69
- "@o3r/build-helpers": "^9.0.0-rc.1",
70
- "@o3r/eslint-plugin": "^9.0.0-rc.1",
71
- "@o3r/schematics": "^9.0.0-rc.1",
69
+ "@o3r/build-helpers": "^9.0.0-rc.13",
70
+ "@o3r/eslint-plugin": "^9.0.0-rc.13",
71
+ "@o3r/schematics": "^9.0.0-rc.13",
72
72
  "@openapitools/openapi-generator-cli": "~2.6.0",
73
73
  "@schematics/angular": "~16.0.5",
74
74
  "@types/jest": "~29.5.2",
@@ -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
@@ -19,9 +19,6 @@ export interface NodePackageInstallTaskOptions {
19
19
  }
20
20
  /**
21
21
  * Install dev dependency on your application
22
- *
23
- * Note: it should not be moved to other packages as it should run before the installation
24
- * of peer dependencies
25
22
  */
26
23
  export declare class DevInstall extends NodePackageInstallTask {
27
24
  quiet: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"node-install.d.ts","sourceRoot":"","sources":["../../../schematics/helpers/node-install.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAEhE;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,kBAAkB,CAAC,EAAE,wBAAwB,GAAG,EAAE,GAAG,SAAS,GAAG,IAAI,GAAG,wBAAwB,CAErI;AAED;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,cAAc,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,EAAE,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;GAKG;AACH,qBAAa,UAAW,SAAQ,sBAAsB;IAC7C,KAAK,UAAS;gBAET,OAAO,CAAC,EAAE,6BAA6B;IAMnD,kBAAkB;IACX,eAAe;;;;;;;;;;CAYvB;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,sBAAsB;IAC7C,KAAK,UAAS;gBAET,OAAO,CAAC,EAAE,6BAA6B;IAMnD,kBAAkB;IACX,eAAe;;;;;;;;;;;;;CAavB"}
1
+ {"version":3,"file":"node-install.d.ts","sourceRoot":"","sources":["../../../schematics/helpers/node-install.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAEhE;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,kBAAkB,CAAC,EAAE,wBAAwB,GAAG,EAAE,GAAG,SAAS,GAAG,IAAI,GAAG,wBAAwB,CAErI;AAED;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,cAAc,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,EAAE,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,sBAAsB;IAC7C,KAAK,UAAS;gBAET,OAAO,CAAC,EAAE,6BAA6B;IAMnD,kBAAkB;IACX,eAAe;;;;;;;;;;CAYvB;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,sBAAsB;IAC7C,KAAK,UAAS;gBAET,OAAO,CAAC,EAAE,6BAA6B;IAMnD,kBAAkB;IACX,eAAe;;;;;;;;;;;;;CAavB"}
@@ -14,9 +14,6 @@ function getPackageManagerName(enforcedNpmManager) {
14
14
  exports.getPackageManagerName = getPackageManagerName;
15
15
  /**
16
16
  * Install dev dependency on your application
17
- *
18
- * Note: it should not be moved to other packages as it should run before the installation
19
- * of peer dependencies
20
17
  */
21
18
  class DevInstall extends tasks_1.NodePackageInstallTask {
22
19
  constructor(options) {
@@ -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 = '';
@@ -8,5 +8,14 @@ export interface NgGenerateTypescriptSDKCoreSchematicsSchema extends JsonObject
8
8
  packageManager: 'npm' | 'yarn' | '';
9
9
  /** Path to the spec generation configuration */
10
10
  specConfigPath: string;
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
+ *
17
+ * @default ''
18
+ */
19
+ globalProperty: string;
11
20
  }
12
21
  //# 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,CAAC;IAElB,sDAAsD;IACtD,cAAc,EAAE,KAAK,GAAG,MAAM,GAAG,EAAE,CAAC;IAEpC,gDAAgD;IAChD,cAAc,EAAE,MAAM,CAAC;CACxB"}
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,CAAC;IAElB,sDAAsD;IACtD,cAAc,EAAE,KAAK,GAAG,MAAM,GAAG,EAAE,CAAC;IAEpC,gDAAgD;IAChD,cAAc,EAAE,MAAM,CAAC;IAEvB;;;;;;;OAOG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB"}
@@ -32,6 +32,11 @@
32
32
  ],
33
33
  "description": "Package manager to be used in the generated SDK",
34
34
  "default": ""
35
+ },
36
+ "globalProperty": {
37
+ "type": "string",
38
+ "description": "Comma separated string of options to give to the openapi-generator-cli",
39
+ "default": ""
35
40
  }
36
41
  },
37
42
  "additionalProperties": true,
@@ -1,8 +1,8 @@
1
1
  import type { JsonObject } from '@angular-devkit/core';
2
2
  export interface NgGenerateTypescriptSDKShellSchematicsSchema extends JsonObject {
3
- /** Project name (NPM package scope) */
3
+ /** Project name (NPM package scope, package.json name will be @{projectName}/{packageName}) */
4
4
  name: string;
5
- /** Package name */
5
+ /** Package name (package.json name will be @{projectName}/{packageName}) */
6
6
  package: string;
7
7
  /** Project description */
8
8
  description: string;
@@ -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,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IAEb,mBAAmB;IACnB,OAAO,EAAE,MAAM,CAAC;IAEhB,0BAA0B;IAC1B,WAAW,EAAE,MAAM,CAAC;IAEpB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAElB,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,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,CAAC;IAEpB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAElB,sDAAsD;IACtD,cAAc,EAAE,KAAK,GAAG,MAAM,GAAG,EAAE,CAAC;IAEpC,uBAAuB;IACvB,WAAW,EAAE,OAAO,CAAC;CACtB"}
@@ -6,13 +6,13 @@
6
6
  "properties": {
7
7
  "name": {
8
8
  "type": "string",
9
- "description": "Project name (NPM package scope)",
10
- "x-prompt": "Project name (NPM package scope)?"
9
+ "description": "Project name (NPM package scope, package.json name will be @{projectName}/{packageName})",
10
+ "x-prompt": "Project name (NPM package scope, package.json name will be @{projectName}/{packageName})?"
11
11
  },
12
12
  "package": {
13
13
  "type": "string",
14
- "description": "Package name",
15
- "x-prompt": "Package name?",
14
+ "description": "Package name (package.json name will be @{projectName}/{packageName})",
15
+ "x-prompt": "Package name (package.json name will be @{projectName}/{packageName})?",
16
16
  "default": "sdk"
17
17
  },
18
18
  "description": {
@@ -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