Skip to content

Commit a7439e4

Browse files
alethystLaith Hussein
andauthored
feat(typescript-angular): add support for v17 of angular (#17685)
- Add support for `transferCache` property in request options Refs: [#17301] Co-authored-by: Laith Hussein <laith.hussein@beno.com>
1 parent 96eb4a4 commit a7439e4

33 files changed

Lines changed: 4945 additions & 10977 deletions

File tree

CI/circle_parallel.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ elif [ "$NODE_INDEX" = "3" ]; then
6969
(cd samples/client/petstore/typescript-angular-v14-provided-in-root && mvn integration-test)
7070
(cd samples/client/petstore/typescript-angular-v15-provided-in-root && mvn integration-test)
7171
(cd samples/client/petstore/typescript-angular-v16-provided-in-root && mvn integration-test)
72+
(cd samples/client/petstore/typescript-angular-v17-provided-in-root && mvn integration-test)
7273
(cd samples/openapi3/client/petstore/typescript/builds/default && mvn integration-test)
7374
(cd samples/openapi3/client/petstore/typescript/tests/default && mvn integration-test)
7475
(cd samples/openapi3/client/petstore/typescript/builds/jquery && mvn integration-test)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
8080

8181
| | Languages/Frameworks |
8282
| -------------------------------- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
83-
| **API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.1, .NET Core 3.1, .NET 5.0. Libraries: RestSharp, GenericHost, HttpClient), **C++** (Arduino, cpp-restsdk, Qt5, Tizen, Unreal Engine 4), **Clojure**, **Crystal**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Apache HttpClient 4.x, Apache HttpClient 5.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client, MicroProfile Rest Client, Helidon), **Jetbrains HTTP Client**, **Julia**, **k6**, **Kotlin**, **Lua**, **N4JS**, **Nim**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types, Apollo GraphQL DataStore), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (hyper, reqwest, rust-server), **Scala** (akka, http4s, scalaz, sttp, swagger-async-httpclient, pekko), **Swift** (2.x, 3.x, 4.x, 5.x), **Typescript** (AngularJS, Angular (9.x - 16.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs), **XoJo**, **Zapier** |
83+
| **API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.1, .NET Core 3.1, .NET 5.0. Libraries: RestSharp, GenericHost, HttpClient), **C++** (Arduino, cpp-restsdk, Qt5, Tizen, Unreal Engine 4), **Clojure**, **Crystal**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Apache HttpClient 4.x, Apache HttpClient 5.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client, MicroProfile Rest Client, Helidon), **Jetbrains HTTP Client**, **Julia**, **k6**, **Kotlin**, **Lua**, **N4JS**, **Nim**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types, Apollo GraphQL DataStore), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (hyper, reqwest, rust-server), **Scala** (akka, http4s, scalaz, sttp, swagger-async-httpclient, pekko), **Swift** (2.x, 3.x, 4.x, 5.x), **Typescript** (AngularJS, Angular (9.x - 17.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs), **XoJo**, **Zapier** |
8484
| **Server stubs** | **Ada**, **C#** (ASP.NET Core, Azure Functions), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant, Yesod), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/), [Apache Camel](https://camel.apache.org/), [Helidon](https://helidon.io/)), **Julia**, **Kotlin** (Spring Boot, [Ktor](https://github.com/ktorio/ktor), [Vert.x](https://vertx.io/)), **PHP** (Laravel, Lumen, [Mezzio (fka Zend Expressive)](https://github.com/mezzio/mezzio), Slim, Silex, [Symfony](https://symfony.com/)), **Python** (FastAPI, Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** ([rust-server](https://openapi-generator.tech/docs/generators/rust-server/)), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra) |
8585
| **API documentation generators** | **HTML**, **Confluence Wiki**, **Asciidoc**, **Markdown**, **PlantUML** |
8686
| **Configuration files** | [**Apache2**](https://httpd.apache.org/) |
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
generatorName: typescript-angular
2+
outputDir: samples/client/petstore/typescript-angular-v17-provided-in-root/builds/default
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/typescript-angular
5+
additionalProperties:
6+
ngVersion: 17.0.0
7+
supportsES6: true

docs/generators/typescript-angular.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ title: Documentation for the typescript-angular Generator
1111
| generator type | CLIENT | |
1212
| generator language | Typescript | |
1313
| generator default templating engine | mustache | |
14-
| helpTxt | Generates a TypeScript Angular (9.x - 16.x) client library. | |
14+
| helpTxt | Generates a TypeScript Angular (9.x - 17.x) client library. | |
1515

1616
## CONFIG OPTIONS
1717
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
@@ -32,7 +32,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
3232
|modelFileSuffix|The suffix of the file of the generated model (model&lt;suffix&gt;.ts).| |null|
3333
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name. Only change it if you provide your own run-time code for (de-)serialization of models| |original|
3434
|modelSuffix|The suffix of the generated model.| |null|
35-
|ngVersion|The version of Angular. (At least 9.0.0)| |16.1.2|
35+
|ngVersion|The version of Angular. (At least 9.0.0)| |17.0.0|
3636
|npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null|
3737
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
3838
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public static enum PROVIDED_IN_LEVEL {none, root, any, platform}
6161
public static final String PROVIDED_IN = "providedIn";
6262
public static final String ENFORCE_GENERIC_MODULE_WITH_PROVIDERS = "enforceGenericModuleWithProviders";
6363
public static final String HTTP_CONTEXT_IN_OPTIONS = "httpContextInOptions";
64+
public static final String HTTP_TRANSFER_CACHE_IN_OPTIONS = "httpTransferCacheInOptions";
6465
public static final String API_MODULE_PREFIX = "apiModulePrefix";
6566
public static final String CONFIGURATION_PREFIX = "configurationPrefix";
6667
public static final String SERVICE_SUFFIX = "serviceSuffix";
@@ -72,7 +73,7 @@ public static enum PROVIDED_IN_LEVEL {none, root, any, platform}
7273
public static final String STRING_ENUMS_DESC = "Generate string enums instead of objects for enum values.";
7374
public static final String QUERY_PARAM_OBJECT_FORMAT = "queryParamObjectFormat";
7475

75-
protected String ngVersion = "16.1.2";
76+
protected String ngVersion = "17.0.0";
7677
protected String npmRepository = null;
7778
private boolean useSingleRequestParameter = false;
7879
protected String serviceSuffix = "Service";
@@ -152,7 +153,7 @@ public String getName() {
152153

153154
@Override
154155
public String getHelp() {
155-
return "Generates a TypeScript Angular (9.x - 16.x) client library.";
156+
return "Generates a TypeScript Angular (9.x - 17.x) client library.";
156157
}
157158

158159
@Override
@@ -226,6 +227,10 @@ public void processOpts() {
226227
additionalProperties.put(HTTP_CONTEXT_IN_OPTIONS, true);
227228
}
228229

230+
if (ngVersion.atLeast("17.0.0")) {
231+
additionalProperties.put(HTTP_TRANSFER_CACHE_IN_OPTIONS, true);
232+
}
233+
229234
additionalProperties.put(NG_VERSION, ngVersion);
230235

231236
if (additionalProperties.containsKey(API_MODULE_PREFIX)) {
@@ -283,7 +288,9 @@ private void addNpmPackageGeneration(SemVer ngVersion) {
283288

284289
// Set the typescript version compatible to the Angular version
285290
// based on https://angular.io/guide/versions#actively-supported-versions
286-
if (ngVersion.atLeast("16.1.0")) {
291+
if (ngVersion.atLeast("17.0.0")) {
292+
additionalProperties.put("tsVersion", ">=4.9.3 <5.3.0");
293+
} else if (ngVersion.atLeast("16.1.0")) {
287294
additionalProperties.put("tsVersion", ">=4.9.3 <5.2.0");
288295
} else if (ngVersion.atLeast("16.0.0")) {
289296
additionalProperties.put("tsVersion", ">=4.9.3 <5.1.0");
@@ -306,7 +313,9 @@ private void addNpmPackageGeneration(SemVer ngVersion) {
306313
}
307314

308315
// Set the rxJS version compatible to the Angular version
309-
if (ngVersion.atLeast("16.0.0")) {
316+
if (ngVersion.atLeast("17.0.0")) {
317+
additionalProperties.put("rxjsVersion", "7.4.0");
318+
} else if (ngVersion.atLeast("16.0.0")) {
310319
additionalProperties.put("rxjsVersion", "7.4.0");
311320
} else if (ngVersion.atLeast("15.0.0")) {
312321
additionalProperties.put("rxjsVersion", "7.5.5");
@@ -323,7 +332,11 @@ private void addNpmPackageGeneration(SemVer ngVersion) {
323332
supportingFiles.add(new SupportingFile("ng-package.mustache", getIndexDirectory(), "ng-package.json"));
324333

325334
// Specific ng-packagr configuration
326-
if (ngVersion.atLeast("16.0.0")) {
335+
if (ngVersion.atLeast("17.0.0")) {
336+
additionalProperties.put("ngPackagrVersion", "17.0.3");
337+
// tsTickle is not required and there is no available version compatible with
338+
// versions of TypeScript compatible with Angular 17.
339+
} else if (ngVersion.atLeast("16.0.0")) {
327340
additionalProperties.put("ngPackagrVersion", "16.0.0");
328341
// tsTickle is not required and there is no available version compatible with
329342
// versions of TypeScript compatible with Angular 16.
@@ -352,7 +365,9 @@ private void addNpmPackageGeneration(SemVer ngVersion) {
352365
}
353366

354367
// set zone.js version
355-
if (ngVersion.atLeast("16.0.0")) {
368+
if (ngVersion.atLeast("17.0.0")) {
369+
additionalProperties.put("zonejsVersion", "0.14.0");
370+
} else if (ngVersion.atLeast("16.0.0")) {
356371
additionalProperties.put("zonejsVersion", "0.13.0");
357372
} else if (ngVersion.atLeast("15.0.0")) {
358373
additionalProperties.put("zonejsVersion", "0.11.5");

0 commit comments

Comments
 (0)