@ama-sdk/schematics 10.0.0-prerelease.101 → 10.0.0-prerelease.103
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 +28 -14
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
This package provides `schematics` generators to create an SDK based on an OpenAPI specifications.
|
|
4
4
|
There are two SDK generators in the Otter Framework: Typescript and Java. The Java generator is currently in maintenance
|
|
5
5
|
mode and only the Typescript generator is actively supported and will see future evolutions.
|
|
6
|
+
|
|
6
7
|
- [Typescript SDK](#typescript-sdk)
|
|
7
8
|
- [Java SDK](#java-client-core-sdk)
|
|
8
9
|
|
|
@@ -11,6 +12,7 @@ mode and only the Typescript generator is actively supported and will see future
|
|
|
11
12
|
The Typescript SDK generator is a custom template for the OpenAPITools generator with a full integration of the [@ama-sdk/core](https://www.npmjs.com/package/@ama-sdk/core) client capabilities.
|
|
12
13
|
|
|
13
14
|
It supports both Swagger 2+ and Open API 3 specifications.
|
|
15
|
+
|
|
14
16
|
- [Setup](#setup)
|
|
15
17
|
- [How to use](#how-to-use)
|
|
16
18
|
- [Debug](#debug)
|
|
@@ -27,14 +29,17 @@ npm create @ama-sdk typescript <project-name> -- [--spec-path=./path/to/spec.yam
|
|
|
27
29
|
```
|
|
28
30
|
|
|
29
31
|
or
|
|
32
|
+
|
|
30
33
|
```shell
|
|
31
34
|
yarn create @ama-sdk typescript <project-name> [--spec-path=./path/to/spec.yaml]
|
|
32
35
|
```
|
|
33
36
|
|
|
34
|
-
>
|
|
37
|
+
> [!WARNING]
|
|
38
|
+
> Please notice that the command `yarn create` is **not** available for versions *>= 2.0.0*
|
|
35
39
|
> (see [Yarn cli commands](https://yarnpkg.com/cli)).
|
|
36
40
|
|
|
37
|
-
>
|
|
41
|
+
> [!TIP]
|
|
42
|
+
> Get more information on the [@ama-sdk/create package](https://www.npmjs.com/package/@ama-sdk/create).
|
|
38
43
|
|
|
39
44
|
#### Create a new Otter workspace package
|
|
40
45
|
|
|
@@ -83,57 +88,66 @@ Use `generate` to (re)generate your SDK based on the content of `./swagger-spec.
|
|
|
83
88
|
It is also possible to generate a "light" SDK. This type of SDK does not need to generate revivers, which results in a simplified version of the code and reduces the size of the bundle.
|
|
84
89
|
|
|
85
90
|
Please note that revivers are generated for SDKs that use:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
91
|
+
- non-stringified dates
|
|
92
|
+
- dictionaries
|
|
93
|
+
- extensible models
|
|
89
94
|
|
|
90
95
|
##### Dates
|
|
91
|
-
|
|
92
|
-
|
|
96
|
+
|
|
97
|
+
If your specification file includes dates, there are multiple options for the generation of your SDK involving the global property option `stringifyDate`:
|
|
98
|
+
- By default, the option `stringifyDate` is false so dates will be generated as either `utils.Date`, `utils.DateTime`, or `Date`.
|
|
93
99
|
For more information related to these types, check out this [documentation](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/schematics/schematics/typescript/shell/templates/base#manage-dates).
|
|
94
|
-
|
|
100
|
+
- To leave the handling of the timezone to the application and generate the dates as `string` types, the option `stringifyDate` can be set to true. <br>
|
|
95
101
|
This can be done by adding `--global-property stringifyDate` to the generator command.
|
|
96
|
-
|
|
102
|
+
- If an existing SDK contains stringified dates that need to be reverted to their expected formats, you can regenerate the SDK by removing the `stringifyDate` option from the global properties (since it is false by default).
|
|
97
103
|
|
|
98
104
|
Example to stringify dates:
|
|
105
|
+
|
|
99
106
|
```shell
|
|
100
107
|
yarn schematics @ama-sdk/schematics:typescript-core --spec-path ./swagger-spec.yaml --global-property stringifyDate
|
|
101
108
|
```
|
|
102
109
|
|
|
103
110
|
##### Extensible models
|
|
104
111
|
|
|
105
|
-
You may be in a case in which you want to be able to extend your SDK models and therefore ensure that revivers are generated
|
|
106
|
-
(more info on how to extend a model [here](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/schematics/schematics/typescript/shell/templates/base#how-to-extend-a-model)).
|
|
112
|
+
You may be in a case in which you want to be able to extend your SDK models and therefore ensure that revivers are generated
|
|
113
|
+
(more info on how to extend a model [here](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/schematics/schematics/typescript/shell/templates/base#how-to-extend-a-model)).
|
|
107
114
|
To do this, you can use the global property option `allowModelExtension` by adding `--global-property allowModelExtension` to the generator command.
|
|
108
115
|
|
|
109
116
|
Example:
|
|
117
|
+
|
|
110
118
|
```shell
|
|
111
119
|
yarn schematics @ama-sdk/schematics:typescript-core --spec-path ./swagger-spec.yaml --global-property allowModelExtension
|
|
112
120
|
```
|
|
113
121
|
|
|
114
122
|
### Debug
|
|
123
|
+
|
|
115
124
|
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.
|
|
116
125
|
If there is an issue with the files generated with the spec provided, the generator provides debugging features that log this data model.
|
|
117
126
|
|
|
118
127
|
You can use global property options to pass one or both of the following options:
|
|
119
|
-
|
|
120
|
-
|
|
128
|
+
- debugModels - logs the full JSON structure used to generate models
|
|
129
|
+
- debugOperations - logs the full JSON structure used to generate operations
|
|
121
130
|
|
|
122
131
|
Example:
|
|
132
|
+
|
|
123
133
|
```shell
|
|
124
134
|
yarn schematics @ama-sdk/schematics:typescript-core --spec-path ./swagger-spec.yaml --global-property debugModels,debugOperations
|
|
125
135
|
```
|
|
136
|
+
|
|
126
137
|
You can also use npx instead of yarn in the command.
|
|
127
138
|
|
|
128
139
|
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.
|
|
129
140
|
|
|
130
141
|
### Going further
|
|
142
|
+
|
|
131
143
|
For more information on the generated SDK and how the framework supports different feature such as the Composition, you can refer to the dedicated SDK documentation:
|
|
144
|
+
|
|
132
145
|
- [Generated SDK hierarchy and extension](https://github.com/AmadeusITGroup/otter/blob/main/docs/api-sdk/SDK_MODELS_HIERARCHY.md)
|
|
133
146
|
- [Composition and Inheritance support](https://github.com/AmadeusITGroup/otter/blob/main/docs/api-sdk/COMPOSITION_INHERITANCE.md)
|
|
134
147
|
|
|
135
148
|
## Java Client Core SDK
|
|
136
|
-
|
|
149
|
+
|
|
150
|
+
> [!WARNING]
|
|
137
151
|
> This feature is on maintenance mode and will see no future evolution
|
|
138
152
|
|
|
139
153
|
Generate a Java Client Core SDK:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ama-sdk/schematics",
|
|
3
|
-
"version": "10.0.0-prerelease.
|
|
3
|
+
"version": "10.0.0-prerelease.103",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@ama-sdk/core": "^10.0.0-prerelease.
|
|
51
|
+
"@ama-sdk/core": "^10.0.0-prerelease.103",
|
|
52
52
|
"@angular-devkit/core": "~17.2.0",
|
|
53
53
|
"@angular-devkit/schematics": "~17.2.0",
|
|
54
54
|
"@angular-devkit/schematics-cli": "^17.0.1",
|
|
55
55
|
"@angular/cli": "^17.0.1",
|
|
56
|
-
"@o3r/schematics": "^10.0.0-prerelease.
|
|
56
|
+
"@o3r/schematics": "^10.0.0-prerelease.103",
|
|
57
57
|
"@openapitools/openapi-generator-cli": "~2.9.0",
|
|
58
58
|
"@schematics/angular": "~17.2.0"
|
|
59
59
|
},
|
|
@@ -68,16 +68,16 @@
|
|
|
68
68
|
"tslib": "^2.5.3"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@ama-sdk/core": "^10.0.0-prerelease.
|
|
71
|
+
"@ama-sdk/core": "^10.0.0-prerelease.103",
|
|
72
72
|
"@angular-devkit/schematics-cli": "~17.2.0",
|
|
73
73
|
"@angular-eslint/eslint-plugin": "~17.2.0",
|
|
74
74
|
"@angular/cli": "~17.2.0",
|
|
75
75
|
"@nx/eslint-plugin": "~18.0.2",
|
|
76
76
|
"@nx/jest": "~18.0.2",
|
|
77
|
-
"@o3r/build-helpers": "^10.0.0-prerelease.
|
|
78
|
-
"@o3r/eslint-plugin": "^10.0.0-prerelease.
|
|
79
|
-
"@o3r/schematics": "^10.0.0-prerelease.
|
|
80
|
-
"@o3r/test-helpers": "^10.0.0-prerelease.
|
|
77
|
+
"@o3r/build-helpers": "^10.0.0-prerelease.103",
|
|
78
|
+
"@o3r/eslint-plugin": "^10.0.0-prerelease.103",
|
|
79
|
+
"@o3r/schematics": "^10.0.0-prerelease.103",
|
|
80
|
+
"@o3r/test-helpers": "^10.0.0-prerelease.103",
|
|
81
81
|
"@openapitools/openapi-generator-cli": "~2.9.0",
|
|
82
82
|
"@schematics/angular": "~17.2.0",
|
|
83
83
|
"@stylistic/eslint-plugin-ts": "^1.5.4",
|