Skip to content

Commit

Permalink
Add support for Angular v14 (#12901)
Browse files Browse the repository at this point in the history
* Add support for Angular v14

- Support Angular 14
- Support rxjs 7.5.5, tsickle 0.46.3, ngPackagr 14.0.2, zonejs 0.11.5
- Requires typescript >= 4.6.0 and < 4.8.0

* Review comments

- Remove duplicate tests
- Added openapi-generator-ignore

* Update samples/client/petstore/typescript-angular-v14-provided-in-root/pom.xml

* Update samples/client/petstore/typescript-angular-v14-provided-in-root/pom.xml

* Update samples/client/petstore/typescript-angular-v14-provided-in-root/pom.xml

* Review comments

- Added typescript-angular-v14-provided-in-root test module to root pom.

* update samples

Co-authored-by: Esteban Gehring <[email protected]>
Co-authored-by: Esteban Gehring <[email protected]>
  • Loading branch information
3 people authored Aug 17, 2022
1 parent 01a9c55 commit 904674c
Show file tree
Hide file tree
Showing 77 changed files with 27,307 additions and 8 deletions.
7 changes: 7 additions & 0 deletions bin/configs/typescript-angular-v14-provided-in-root.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
generatorName: typescript-angular
outputDir: samples/client/petstore/typescript-angular-v14-provided-in-root/builds/default
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/typescript-angular
additionalProperties:
ngVersion: 14.0.5
supportsES6: true
4 changes: 2 additions & 2 deletions docs/generators/typescript-angular.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ title: Documentation for the typescript-angular Generator
| generator type | CLIENT | |
| generator language | Typescript | |
| generator default templating engine | mustache | |
| helpTxt | Generates a TypeScript Angular (9.x - 13.x) client library. | |
| helpTxt | Generates a TypeScript Angular (9.x - 14.x) client library. | |

## CONFIG OPTIONS
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.
Expand All @@ -31,7 +31,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|modelFileSuffix|The suffix of the file of the generated model (model&lt;suffix&gt;.ts).| |null|
|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|
|modelSuffix|The suffix of the generated model.| |null|
|ngVersion|The version of Angular. (At least 9.0.0)| |13.0.1|
|ngVersion|The version of Angular. (At least 9.0.0)| |14.0.5|
|npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null|
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static enum PROVIDED_IN_LEVEL {none, root, any, platform}
public static final String STRING_ENUMS_DESC = "Generate string enums instead of objects for enum values.";
public static final String QUERY_PARAM_OBJECT_FORMAT = "queryParamObjectFormat";

protected String ngVersion = "13.0.1";
protected String ngVersion = "14.0.5";
protected String npmRepository = null;
private boolean useSingleRequestParameter = false;
protected String serviceSuffix = "Service";
Expand Down Expand Up @@ -145,7 +145,7 @@ public String getName() {

@Override
public String getHelp() {
return "Generates a TypeScript Angular (9.x - 13.x) client library.";
return "Generates a TypeScript Angular (9.x - 14.x) client library.";
}

@Override
Expand Down Expand Up @@ -274,7 +274,9 @@ private void addNpmPackageGeneration(SemVer ngVersion) {
}

// Set the typescript version compatible to the Angular version
if (ngVersion.atLeast("13.0.0")) {
if (ngVersion.atLeast("14.0.0")) {
additionalProperties.put("tsVersion", ">=4.6.0 <=4.8.0");
} else if (ngVersion.atLeast("13.0.0")) {
additionalProperties.put("tsVersion", ">=4.4.2 <4.5.0");
} else if (ngVersion.atLeast("12.0.0")) {
additionalProperties.put("tsVersion", ">=4.3.0 <4.4.0");
Expand All @@ -289,7 +291,9 @@ private void addNpmPackageGeneration(SemVer ngVersion) {
}

// Set the rxJS version compatible to the Angular version
if (ngVersion.atLeast("13.0.0")) {
if (ngVersion.atLeast("14.0.0")) {
additionalProperties.put("rxjsVersion", "7.5.5");
} else if (ngVersion.atLeast("13.0.0")) {
additionalProperties.put("rxjsVersion", "7.4.0");
} else if (ngVersion.atLeast("10.0.0")) {
additionalProperties.put("rxjsVersion", "6.6.0");
Expand All @@ -300,7 +304,10 @@ private void addNpmPackageGeneration(SemVer ngVersion) {
supportingFiles.add(new SupportingFile("ng-package.mustache", getIndexDirectory(), "ng-package.json"));

// Specific ng-packagr configuration
if (ngVersion.atLeast("13.0.0")) {
if (ngVersion.atLeast("14.0.0")) {
additionalProperties.put("ngPackagrVersion", "14.0.2");
additionalProperties.put("tsickleVersion", "0.46.3");
} else if (ngVersion.atLeast("13.0.0")) {
additionalProperties.put("ngPackagrVersion", "13.0.3");
additionalProperties.put("tsickleVersion", "0.43.0");
} else if (ngVersion.atLeast("12.0.0")) {
Expand All @@ -318,7 +325,9 @@ private void addNpmPackageGeneration(SemVer ngVersion) {
}

// set zone.js version
if (ngVersion.atLeast("12.0.0")) {
if (ngVersion.atLeast("14.0.0")) {
additionalProperties.put("zonejsVersion", "0.11.5");
} else if (ngVersion.atLeast("12.0.0")) {
additionalProperties.put("zonejsVersion", "0.11.4");
} else if (ngVersion.atLeast("11.0.0")) {
additionalProperties.put("zonejsVersion", "0.11.3");
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,7 @@
<module>samples/client/petstore/typescript-jquery/npm</module>-->
<module>samples/client/petstore/typescript-angular-v12-provided-in-root</module>
<module>samples/client/petstore/typescript-angular-v13-provided-in-root</module>
<module>samples/client/petstore/typescript-angular-v14-provided-in-root</module>
<module>samples/openapi3/client/petstore/typescript/builds/default</module>
<module>samples/openapi3/client/petstore/typescript/tests/default</module>
<module>samples/openapi3/client/petstore/typescript/builds/jquery</module>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/out-tsc

# dependencies
/node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db

.angular
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "tests",
"projects": {
"test-default": {
"root": "tests/default",
"sourceRoot": "tests/default/src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"aot": true,
"outputPath": "tests/default/dist",
"index": "tests/default/src/index.html",
"main": "tests/default/src/main.ts",
"polyfills": "tests/default/src/polyfills.ts",
"tsConfig": "tests/default/src/tsconfig.app.json",
"assets": [
"tests/default/src/favicon.ico",
"tests/default/src/assets"
],
"styles": [
"tests/default/src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
"fileReplacements": [
{
"replace": "tests/default/src/environments/environment.ts",
"with": "tests/default/src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
},
"development": {}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
},
"configurations": {
"production": {
"browserTarget": "test-default:build:production"
},
"development": {
"browserTarget": "test-default:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "test-default:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "tests/default/src/test.ts",
"polyfills": "tests/default/src/polyfills.ts",
"tsConfig": "tests/default/src/tsconfig.spec.json",
"karmaConfig": "tests/default/src/karma.conf.js",
"styles": [
"tests/default/src/styles.css"
],
"scripts": [],
"assets": [
"tests/default/src/favicon.ico",
"tests/default/src/assets"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"tests/default/src/tsconfig.app.json",
"tests/default/src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "test-default"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
wwwroot/*.js
node_modules
typings
dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.gitignore
README.md
api.module.ts
api/api.ts
api/pet.service.ts
api/store.service.ts
api/user.service.ts
configuration.ts
encoder.ts
git_push.sh
index.ts
model/apiResponse.ts
model/category.ts
model/models.ts
model/order.ts
model/pet.ts
model/tag.ts
model/user.ts
variables.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.1.0-SNAPSHOT
Loading

0 comments on commit 904674c

Please sign in to comment.