mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2026-03-18 20:49:04 +00:00
[typescript-angular] add provided in support (#120)
* add provided in root support * fix unit test to pass test generation of new options * set default for providedInRoot to be true
This commit is contained in:
@@ -42,6 +42,8 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
public static final String WITH_INTERFACES = "withInterfaces";
|
||||
public static final String TAGGED_UNIONS = "taggedUnions";
|
||||
public static final String NG_VERSION = "ngVersion";
|
||||
public static final String PROVIDED_IN_ROOT ="providedInRoot";
|
||||
|
||||
|
||||
protected String npmName = null;
|
||||
protected String npmVersion = "1.0.0";
|
||||
@@ -75,6 +77,9 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
this.cliOptions.add(new CliOption(TAGGED_UNIONS,
|
||||
"Use discriminators to create tagged unions instead of extending interfaces.",
|
||||
SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||
this.cliOptions.add(new CliOption(PROVIDED_IN_ROOT,
|
||||
"Use this property to provide Injectables in root (it is only valid in angular version greater or equal to 6.0.0).",
|
||||
SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||
this.cliOptions.add(new CliOption(NG_VERSION, "The version of Angular. Default is '4.3'"));
|
||||
}
|
||||
|
||||
@@ -135,6 +140,17 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
taggedUnions = Boolean.parseBoolean(additionalProperties.get(TAGGED_UNIONS).toString());
|
||||
}
|
||||
|
||||
if (ngVersion.atLeast("6.0.0")) {
|
||||
if (!additionalProperties.containsKey(PROVIDED_IN_ROOT)){
|
||||
additionalProperties.put(PROVIDED_IN_ROOT,true);
|
||||
}else {
|
||||
additionalProperties.put(PROVIDED_IN_ROOT,Boolean.valueOf(
|
||||
(String) additionalProperties.get(PROVIDED_IN_ROOT)));
|
||||
}
|
||||
}else {
|
||||
additionalProperties.put(PROVIDED_IN_ROOT,false);
|
||||
}
|
||||
|
||||
additionalProperties.put(NG_VERSION, ngVersion);
|
||||
additionalProperties.put("injectionToken", ngVersion.atLeast("4.0.0") ? "InjectionToken" : "OpaqueToken");
|
||||
additionalProperties.put("injectionTokenTyped", ngVersion.atLeast("4.0.0"));
|
||||
|
||||
Reference in New Issue
Block a user