Skip to content

Commit 71528f6

Browse files
Add support for Angular 16 (OpenAPITools#15925)
* Add support for Angular 16 * Fix dependencies specifications * Fix minimum angular supported version in readme * Update integration tests Even if they are currently not run. * Update sample due to rebase
1 parent d6538e3 commit 71528f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+27614
-59
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
7373

7474
| | Languages/Frameworks |
7575
| -------------------------------- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
76-
| **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, Jersey1.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), **Swift** (2.x, 3.x, 4.x, 5.x), **Typescript** (AngularJS, Angular (2.x - 15.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs), **XoJo** |
76+
| **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, Jersey1.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), **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** |
7777
| **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) |
7878
| **API documentation generators** | **HTML**, **Confluence Wiki**, **Asciidoc**, **Markdown**, **PlantUML** |
7979
| **Configuration files** | [**Apache2**](https://httpd.apache.org/) |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
generatorName: typescript-angular
2+
outputDir: samples/client/petstore/typescript-angular-v16-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: 16.1.2
7+
supportsES6: true

docs/generators/typescript-angular.md

+2-2
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 - 15.x) client library. | |
14+
| helpTxt | Generates a TypeScript Angular (9.x - 16.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.
@@ -31,7 +31,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
3131
|modelFileSuffix|The suffix of the file of the generated model (model<suffix>.ts).| |null|
3232
|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|
3333
|modelSuffix|The suffix of the generated model.| |null|
34-
|ngVersion|The version of Angular. (At least 9.0.0)| |15.0.3|
34+
|ngVersion|The version of Angular. (At least 9.0.0)| |16.1.2|
3535
|npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null|
3636
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
3737
|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

+19-6
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static enum PROVIDED_IN_LEVEL {none, root, any, platform}
7272
public static final String STRING_ENUMS_DESC = "Generate string enums instead of objects for enum values.";
7373
public static final String QUERY_PARAM_OBJECT_FORMAT = "queryParamObjectFormat";
7474

75-
protected String ngVersion = "15.0.3";
75+
protected String ngVersion = "16.1.2";
7676
protected String npmRepository = null;
7777
private boolean useSingleRequestParameter = false;
7878
protected String serviceSuffix = "Service";
@@ -152,7 +152,7 @@ public String getName() {
152152

153153
@Override
154154
public String getHelp() {
155-
return "Generates a TypeScript Angular (9.x - 15.x) client library.";
155+
return "Generates a TypeScript Angular (9.x - 16.x) client library.";
156156
}
157157

158158
@Override
@@ -282,7 +282,12 @@ private void addNpmPackageGeneration(SemVer ngVersion) {
282282
}
283283

284284
// Set the typescript version compatible to the Angular version
285-
if (ngVersion.atLeast("15.0.0")) {
285+
// based on https://angular.io/guide/versions#actively-supported-versions
286+
if (ngVersion.atLeast("16.1.0")) {
287+
additionalProperties.put("tsVersion", ">=4.9.3 <5.2.0");
288+
} else if (ngVersion.atLeast("16.0.0")) {
289+
additionalProperties.put("tsVersion", ">=4.9.3 <5.1.0");
290+
} else if (ngVersion.atLeast("15.0.0")) {
286291
additionalProperties.put("tsVersion", ">=4.8.2 <4.10.0");
287292
} else if (ngVersion.atLeast("14.0.0")) {
288293
additionalProperties.put("tsVersion", ">=4.6.0 <=4.8.0");
@@ -301,7 +306,9 @@ private void addNpmPackageGeneration(SemVer ngVersion) {
301306
}
302307

303308
// Set the rxJS version compatible to the Angular version
304-
if (ngVersion.atLeast("15.0.0")) {
309+
if (ngVersion.atLeast("16.0.0")) {
310+
additionalProperties.put("rxjsVersion", "7.4.0");
311+
} else if (ngVersion.atLeast("15.0.0")) {
305312
additionalProperties.put("rxjsVersion", "7.5.5");
306313
} else if (ngVersion.atLeast("14.0.0")) {
307314
additionalProperties.put("rxjsVersion", "7.5.5");
@@ -316,7 +323,11 @@ private void addNpmPackageGeneration(SemVer ngVersion) {
316323
supportingFiles.add(new SupportingFile("ng-package.mustache", getIndexDirectory(), "ng-package.json"));
317324

318325
// Specific ng-packagr configuration
319-
if (ngVersion.atLeast("15.0.0")) {
326+
if (ngVersion.atLeast("16.0.0")) {
327+
additionalProperties.put("ngPackagrVersion", "16.0.0");
328+
// tsTickle is not required and there is no available version compatible with
329+
// versions of TypeScript compatible with Angular 16.
330+
} else if (ngVersion.atLeast("15.0.0")) {
320331
additionalProperties.put("ngPackagrVersion", "15.0.2");
321332
// tsTickle is not required and there is no available version compatible with
322333
// versions of TypeScript compatible with Angular 15.
@@ -341,7 +352,9 @@ private void addNpmPackageGeneration(SemVer ngVersion) {
341352
}
342353

343354
// set zone.js version
344-
if (ngVersion.atLeast("15.0.0")) {
355+
if (ngVersion.atLeast("16.0.0")) {
356+
additionalProperties.put("zonejsVersion", "0.13.0");
357+
} else if (ngVersion.atLeast("15.0.0")) {
345358
additionalProperties.put("zonejsVersion", "0.11.5");
346359
} else if (ngVersion.atLeast("14.0.0")) {
347360
additionalProperties.put("zonejsVersion", "0.11.5");

modules/openapi-generator/src/test/resources/integrationtests/typescript/additional-properties-expected/api.module.ts

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core
22
import { Configuration } from './configuration';
33
import { HttpClient } from '@angular/common/http';
44

5-
import { UserService } from './api/user.service';
65

76
@NgModule({
87
imports: [],

modules/openapi-generator/src/test/resources/integrationtests/typescript/additional-properties-expected/package.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@
1616
"build": "ng-packagr -p ng-package.json"
1717
},
1818
"peerDependencies": {
19-
"@angular/core": "^15.0.3",
20-
"rxjs": "^7.5.5"
19+
"@angular/core": "^16.1.2",
20+
"rxjs": "^7.4.0"
2121
},
2222
"devDependencies": {
23-
"@angular/common": "^15.0.3",
24-
"@angular/compiler": "^15.0.3",
25-
"@angular/compiler-cli": "^15.0.3",
26-
"@angular/core": "^15.0.3",
27-
"@angular/platform-browser": "^15.0.3",
28-
"ng-packagr": "^15.0.2",
23+
"@angular/common": "^16.1.2",
24+
"@angular/compiler": "^16.1.2",
25+
"@angular/compiler-cli": "^16.1.2",
26+
"@angular/core": "^16.1.2",
27+
"@angular/platform-browser": "^16.1.2",
28+
"ng-packagr": "^16.0.0",
2929
"reflect-metadata": "^0.1.3",
30-
"rxjs": "^7.5.5",
31-
"typescript": ">=4.8.2 <4.10.0",
32-
"zone.js": "^0.11.5"
30+
"rxjs": "^7.4.0",
31+
"typescript": ">=4.9.3 <5.2.0",
32+
"zone.js": "^0.13.0"
3333
}}

modules/openapi-generator/src/test/resources/integrationtests/typescript/array-and-object-expected/api.module.ts

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core
22
import { Configuration } from './configuration';
33
import { HttpClient } from '@angular/common/http';
44

5-
import { ProjectService } from './api/project.service';
65

76
@NgModule({
87
imports: [],

modules/openapi-generator/src/test/resources/integrationtests/typescript/array-and-object-expected/package.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@
1616
"build": "ng-packagr -p ng-package.json"
1717
},
1818
"peerDependencies": {
19-
"@angular/core": "^15.0.3",
20-
"rxjs": "^7.5.5"
19+
"@angular/core": "^16.1.2",
20+
"rxjs": "^7.4.0"
2121
},
2222
"devDependencies": {
23-
"@angular/common": "^15.0.3",
24-
"@angular/compiler": "^15.0.3",
25-
"@angular/compiler-cli": "^15.0.3",
26-
"@angular/core": "^15.0.3",
27-
"@angular/platform-browser": "^15.0.3",
28-
"ng-packagr": "^15.0.2",
23+
"@angular/common": "^16.1.2",
24+
"@angular/compiler": "^16.1.2",
25+
"@angular/compiler-cli": "^16.1.2",
26+
"@angular/core": "^16.1.2",
27+
"@angular/platform-browser": "^16.1.2",
28+
"ng-packagr": "^16.0.0",
2929
"reflect-metadata": "^0.1.3",
30-
"rxjs": "^7.5.5",
31-
"typescript": ">=4.8.2 <4.10.0",
32-
"zone.js": "^0.11.5"
30+
"rxjs": "^7.4.0",
31+
"typescript": ">=4.9.3 <5.2.0",
32+
"zone.js": "^0.13.0"
3333
}}

modules/openapi-generator/src/test/resources/integrationtests/typescript/custom-path-params-expected/api.module.ts

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core
22
import { Configuration } from './configuration';
33
import { HttpClient } from '@angular/common/http';
44

5-
import { MatrixParamsService } from './api/matrixParams.service';
65

76
@NgModule({
87
imports: [],

modules/openapi-generator/src/test/resources/integrationtests/typescript/custom-path-params-expected/package.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@
1616
"build": "ng-packagr -p ng-package.json"
1717
},
1818
"peerDependencies": {
19-
"@angular/core": "^15.0.3",
20-
"rxjs": "^7.5.5"
19+
"@angular/core": "^16.1.2",
20+
"rxjs": "^7.4.0"
2121
},
2222
"devDependencies": {
23-
"@angular/common": "^15.0.3",
24-
"@angular/compiler": "^15.0.3",
25-
"@angular/compiler-cli": "^15.0.3",
26-
"@angular/core": "^15.0.3",
27-
"@angular/platform-browser": "^15.0.3",
28-
"ng-packagr": "^15.0.2",
23+
"@angular/common": "^16.1.2",
24+
"@angular/compiler": "^16.1.2",
25+
"@angular/compiler-cli": "^16.1.2",
26+
"@angular/core": "^16.1.2",
27+
"@angular/platform-browser": "^16.1.2",
28+
"ng-packagr": "^16.0.0",
2929
"reflect-metadata": "^0.1.3",
30-
"rxjs": "^7.5.5",
31-
"typescript": ">=4.8.2 <4.10.0",
32-
"zone.js": "^0.11.5"
30+
"rxjs": "^7.4.0",
31+
"typescript": ">=4.9.3 <5.2.0",
32+
"zone.js": "^0.13.0"
3333
}}

modules/openapi-generator/src/test/resources/integrationtests/typescript/petstore-expected/api.module.ts

-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core
22
import { Configuration } from './configuration';
33
import { HttpClient } from '@angular/common/http';
44

5-
import { PetService } from './api/pet.service';
6-
import { StoreService } from './api/store.service';
7-
import { UserService } from './api/user.service';
85

96
@NgModule({
107
imports: [],

modules/openapi-generator/src/test/resources/integrationtests/typescript/petstore-expected/package.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@
1616
"build": "ng-packagr -p ng-package.json"
1717
},
1818
"peerDependencies": {
19-
"@angular/core": "^15.0.3",
20-
"rxjs": "^7.5.5"
19+
"@angular/core": "^16.1.2",
20+
"rxjs": "^7.4.0"
2121
},
2222
"devDependencies": {
23-
"@angular/common": "^15.0.3",
24-
"@angular/compiler": "^15.0.3",
25-
"@angular/compiler-cli": "^15.0.3",
26-
"@angular/core": "^15.0.3",
27-
"@angular/platform-browser": "^15.0.3",
28-
"ng-packagr": "^15.0.2",
23+
"@angular/common": "^16.1.2",
24+
"@angular/compiler": "^16.1.2",
25+
"@angular/compiler-cli": "^16.1.2",
26+
"@angular/core": "^16.1.2",
27+
"@angular/platform-browser": "^16.1.2",
28+
"ng-packagr": "^16.0.0",
2929
"reflect-metadata": "^0.1.3",
30-
"rxjs": "^7.5.5",
31-
"typescript": ">=4.8.2 <4.10.0",
32-
"zone.js": "^0.11.5"
30+
"rxjs": "^7.4.0",
31+
"typescript": ">=4.9.3 <5.2.0",
32+
"zone.js": "^0.13.0"
3333
}}

package-lock.json

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,7 @@
12311231
<module>samples/client/petstore/typescript-angular-v13-provided-in-root</module>
12321232
<module>samples/client/petstore/typescript-angular-v14-provided-in-root</module>
12331233
<module>samples/client/petstore/typescript-angular-v15-provided-in-root</module>
1234+
<module>samples/client/petstore/typescript-angular-v16-provided-in-root</module>
12341235
<module>samples/openapi3/client/petstore/typescript/builds/default</module>
12351236
<module>samples/openapi3/client/petstore/typescript/tests/default</module>
12361237
<module>samples/openapi3/client/petstore/typescript/builds/jquery</module>

0 commit comments

Comments
 (0)