From 6e4ee605ee5a8436f52fe0e7af8abea8277f98d4 Mon Sep 17 00:00:00 2001 From: bezineb5 Date: Sat, 18 Jul 2020 14:49:10 -0400 Subject: [PATCH 1/3] Templatized ModuleWithProviders in typescript-angular The call ModuleWithProviders requires a template: https://angular.io/api/core/ModuleWithProviders Apparently, in Angular 10, this is strictly enforced --- .../resources/handlebars/typescript-angular/api.module.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/handlebars/typescript-angular/api.module.mustache b/src/main/resources/handlebars/typescript-angular/api.module.mustache index 06dad036e6..3e77ae57c8 100644 --- a/src/main/resources/handlebars/typescript-angular/api.module.mustache +++ b/src/main/resources/handlebars/typescript-angular/api.module.mustache @@ -18,7 +18,7 @@ import { {{classname}} } from './{{importPath}}'; {{/hasMore}}{{/apis}}{{/apiInfo}} ] }) export class ApiModule { - public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders { + public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders { return { ngModule: ApiModule, providers: [ { provide: Configuration, useFactory: configurationFactory } ] From 3c0177b356da8e7de8ecded9408016264a675c02 Mon Sep 17 00:00:00 2001 From: bezineb5 Date: Sun, 6 Dec 2020 12:56:15 -0500 Subject: [PATCH 2/3] Keep compatibility with angular <10 --- .../resources/handlebars/typescript-angular/api.module.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/handlebars/typescript-angular/api.module.mustache b/src/main/resources/handlebars/typescript-angular/api.module.mustache index 3e77ae57c8..2953814b3c 100644 --- a/src/main/resources/handlebars/typescript-angular/api.module.mustache +++ b/src/main/resources/handlebars/typescript-angular/api.module.mustache @@ -18,7 +18,7 @@ import { {{classname}} } from './{{importPath}}'; {{/hasMore}}{{/apis}}{{/apiInfo}} ] }) export class ApiModule { - public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders { + public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders{{#genericModuleWithProviders}}{{/genericModuleWithProviders}} { return { ngModule: ApiModule, providers: [ { provide: Configuration, useFactory: configurationFactory } ] From 94aab1232dd47f28bd3e21db411302d858370176 Mon Sep 17 00:00:00 2001 From: bezineb5 Date: Sun, 6 Dec 2020 13:02:14 -0500 Subject: [PATCH 3/3] Automatically add templating if version is at least 7 --- .../typescript/TypeScriptAngularClientCodegen.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/io/swagger/codegen/v3/generators/typescript/TypeScriptAngularClientCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/typescript/TypeScriptAngularClientCodegen.java index ff3598be8e..702045a3c1 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/typescript/TypeScriptAngularClientCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/typescript/TypeScriptAngularClientCodegen.java @@ -152,6 +152,11 @@ public void processOpts() { if (!ngVersion.atLeast("4.3.0")) { supportingFiles.add(new SupportingFile("rxjs-operators.mustache", getIndexDirectory(), "rxjs-operators.ts")); } + + // Version after Angular 10 require ModuleWithProviders to be generic. Compatible from version 7. + if (ngVersion.atLeast("7.0.0")) { + additionalProperties.put("genericModuleWithProviders", true); + } // for Angular 2 AOT support we will use good-old ngc, // Angular Package format wasn't invented at this time and building was much more easier