Skip to content

Commit ec46486

Browse files
committed
Fixed ngPackagr and Angular 8 support
1 parent 2800b12 commit ec46486

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/main/java/io/swagger/codegen/v3/generators/typescript/TypeScriptAngularClientCodegen.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,12 @@ public void processOpts() {
125125
LOGGER.info(" (you can select the angular version by setting the additionalProperty ngVersion)");
126126
}
127127
additionalProperties.put(NG_VERSION, ngVersion);
128+
additionalProperties.put("useNgPackagr", ngVersion.atLeast("8.0.0"));
128129
additionalProperties.put("useRxJS6", ngVersion.atLeast("6.0.0"));
129130
additionalProperties.put("injectionToken", ngVersion.atLeast("4.0.0") ? "InjectionToken" : "OpaqueToken");
130131
additionalProperties.put("injectionTokenTyped", ngVersion.atLeast("4.0.0"));
131132
additionalProperties.put("useHttpClient", ngVersion.atLeast("4.3.0"));
133+
additionalProperties.put("useHttpClientPackage", ngVersion.atLeast("4.3.0") && !ngVersion.atLeast("8.0.0"));
132134
if (!ngVersion.atLeast("4.3.0")) {
133135
supportingFiles.add(new SupportingFile("rxjs-operators.mustache", getIndexDirectory(), "rxjs-operators.ts"));
134136
}

src/main/resources/handlebars/typescript-angular/package.mustache

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
},
2323
{{/useNgPackagr}}
2424
"peerDependencies": {
25-
"@angular/core": "^{{ngVersion}}",
26-
"@angular/http": "^{{ngVersion}}",
25+
"@angular/core": "^{{ngVersion}}",{{#useHttpClientPackage}}
26+
"@angular/http": "^{{ngVersion}}",{{/useHttpClientPackage}}
2727
"@angular/common": "^{{ngVersion}}",
2828
"@angular/compiler": "^{{ngVersion}}",
2929
"core-js": "^2.4.0",
@@ -34,12 +34,12 @@
3434
},
3535
"devDependencies": {
3636
"@angular/compiler-cli": "^{{ngVersion}}",
37-
"@angular/core": "^{{ngVersion}}",
38-
"@angular/http": "^{{ngVersion}}",
37+
"@angular/core": "^{{ngVersion}}",,{{#useHttpClientPackage}}
38+
"@angular/http": "^{{ngVersion}}",{{/useHttpClientPackage}}
3939
"@angular/common": "^{{ngVersion}}",
4040
"@angular/compiler": "^{{ngVersion}}",
4141
"@angular/platform-browser": "^{{ngVersion}}",{{#useNgPackagr}}
42-
"ng-packagr": {{#useOldNgPackagr}}"^1.6.0"{{/useOldNgPackagr}}{{^useOldNgPackagr}}{{#useRxJS6}}"5.3.0"{{/useRxJS6}}{{^useRxJS6}}"^2.4.1"{{/useRxJS6}}{{/useOldNgPackagr}},{{/useNgPackagr}}
42+
"ng-packagr": {{#useOldNgPackagr}}"^1.6.0"{{/useOldNgPackagr}}{{^useOldNgPackagr}}{{#useRxJS6}}"5.5.1"{{/useRxJS6}}{{^useRxJS6}}"^2.4.1"{{/useRxJS6}}{{/useOldNgPackagr}},{{/useNgPackagr}}
4343
"reflect-metadata": "^0.1.3",
4444
"rxjs": "{{#useRxJS6}}~6.3.3{{/useRxJS6}}{{^useRxJS6}}^5.4.0{{/useRxJS6}}",
4545
"zone.js": "^0.7.6",

src/main/resources/mustache/typescript-angular/package.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
},
2323
{{/useNgPackagr}}
2424
"peerDependencies": {
25-
"@angular/core": "^{{ngVersion}}",
26-
"@angular/http": "^{{ngVersion}}",
25+
"@angular/core": "^{{ngVersion}}",{{^useHttpClientPackage}}
26+
"@angular/http": "^{{ngVersion}}",{{/useHttpClientPackage}}
2727
"@angular/common": "^{{ngVersion}}",
2828
"@angular/compiler": "^{{ngVersion}}",
2929
"core-js": "^2.4.0",
@@ -33,8 +33,8 @@
3333
},
3434
"devDependencies": {
3535
"@angular/compiler-cli": "^{{ngVersion}}",
36-
"@angular/core": "^{{ngVersion}}",
37-
"@angular/http": "^{{ngVersion}}",
36+
"@angular/core": "^{{ngVersion}}",{{^useHttpClientPackage}}
37+
"@angular/http": "^{{ngVersion}}",{{/useHttpClientPackage}}
3838
"@angular/common": "^{{ngVersion}}",
3939
"@angular/compiler": "^{{ngVersion}}",
4040
"@angular/platform-browser": "^{{ngVersion}}",{{#useNgPackagr}}

0 commit comments

Comments
 (0)