diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java index a3cd59c3c20b..2ccd6706501d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java @@ -43,11 +43,14 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode public static final String TAGGED_UNIONS = "taggedUnions"; public static final String NG_VERSION = "ngVersion"; public static final String PROVIDED_IN_ROOT ="providedInRoot"; - + public static final String SERVICE_SUFFIX = "serviceSuffix"; + public static final String SERVICE_FILE_SUFFIX = "serviceFileSuffix"; protected String npmName = null; protected String npmVersion = "1.0.0"; protected String npmRepository = null; + protected String serviceSuffix = "Service"; + protected String serviceFileSuffix = ".service"; private boolean taggedUnions = false; @@ -81,6 +84,8 @@ public TypeScriptAngularClientCodegen() { "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'")); + this.cliOptions.add(new CliOption(SERVICE_SUFFIX, "The suffix of the generated service. Default is 'Service'.")); + this.cliOptions.add(new CliOption(SERVICE_FILE_SUFFIX, "The suffix of the file of the generated service (service.ts). Default is '.service'.")); } @Override @@ -159,6 +164,12 @@ public void processOpts() { if (!ngVersion.atLeast("4.3.0")) { supportingFiles.add(new SupportingFile("rxjs-operators.mustache", getIndexDirectory(), "rxjs-operators.ts")); } + if (additionalProperties.containsKey(SERVICE_SUFFIX)) { + serviceSuffix = additionalProperties.get(SERVICE_SUFFIX).toString(); + } + if (additionalProperties.containsKey(SERVICE_FILE_SUFFIX)) { + serviceFileSuffix = additionalProperties.get(SERVICE_FILE_SUFFIX).toString(); + } } private void addNpmPackageGeneration(SemVer ngVersion) { @@ -418,7 +429,7 @@ public String toApiName(String name) { if (name.length() == 0) { return "DefaultService"; } - return initialCaps(name) + "Service"; + return initialCaps(name) + serviceSuffix; } @Override @@ -426,7 +437,7 @@ public String toApiFilename(String name) { if (name.length() == 0) { return "default.service"; } - return camelize(name, true) + ".service"; + return camelize(name, true) + serviceFileSuffix; } @Override @@ -469,7 +480,7 @@ public void setNpmRepository(String npmRepository) { } private String getApiFilenameFromClassname(String classname) { - String name = classname.substring(0, classname.length() - "Service".length()); + String name = classname.substring(0, classname.length() - serviceSuffix.length()); return toApiFilename(name); } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularClientOptionsProvider.java index 35bf14aaa732..8bf3e65827c5 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularClientOptionsProvider.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularClientOptionsProvider.java @@ -35,6 +35,8 @@ public class TypeScriptAngularClientOptionsProvider implements OptionsProvider { public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false"; public static final String NG_VERSION = "2"; public static final String PREPEND_FORM_OR_BODY_PARAMETERS_VALUE = "true"; + public static String SERVICE_SUFFIX = "Service"; + public static String SERVICE_FILE_SUFFIX = ".service"; @Override public String getLanguage() { @@ -56,6 +58,8 @@ public Map createOptions() { .put(TypeScriptAngularClientCodegen.TAGGED_UNIONS, Boolean.FALSE.toString()) .put(TypeScriptAngularClientCodegen.NPM_REPOSITORY, NPM_REPOSITORY) .put(TypeScriptAngularClientCodegen.NG_VERSION, NG_VERSION) + .put(TypeScriptAngularClientCodegen.SERVICE_SUFFIX, SERVICE_SUFFIX) + .put(TypeScriptAngularClientCodegen.SERVICE_FILE_SUFFIX, SERVICE_FILE_SUFFIX) .put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE) .put(CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS, PREPEND_FORM_OR_BODY_PARAMETERS_VALUE) .build(); diff --git a/samples/client/petstore/typescript-angular-v2/default/.openapi-generator/VERSION b/samples/client/petstore/typescript-angular-v2/default/.openapi-generator/VERSION index ad121e8340e0..1c00c5181548 100644 --- a/samples/client/petstore/typescript-angular-v2/default/.openapi-generator/VERSION +++ b/samples/client/petstore/typescript-angular-v2/default/.openapi-generator/VERSION @@ -1 +1 @@ -3.0.1-SNAPSHOT \ No newline at end of file +3.0.2-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/.openapi-generator/VERSION b/samples/client/petstore/typescript-angular-v2/with-interfaces/.openapi-generator/VERSION index ad121e8340e0..1c00c5181548 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/.openapi-generator/VERSION +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/.openapi-generator/VERSION @@ -1 +1 @@ -3.0.1-SNAPSHOT \ No newline at end of file +3.0.2-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/.openapi-generator/VERSION b/samples/client/petstore/typescript-angular-v4.3/npm/.openapi-generator/VERSION index ad121e8340e0..1c00c5181548 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/.openapi-generator/VERSION +++ b/samples/client/petstore/typescript-angular-v4.3/npm/.openapi-generator/VERSION @@ -1 +1 @@ -3.0.1-SNAPSHOT \ No newline at end of file +3.0.2-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript-angular-v4/npm/.openapi-generator/VERSION b/samples/client/petstore/typescript-angular-v4/npm/.openapi-generator/VERSION index ad121e8340e0..1c00c5181548 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/.openapi-generator/VERSION +++ b/samples/client/petstore/typescript-angular-v4/npm/.openapi-generator/VERSION @@ -1 +1 @@ -3.0.1-SNAPSHOT \ No newline at end of file +3.0.2-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/default/.openapi-generator/VERSION b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/default/.openapi-generator/VERSION index ad121e8340e0..1c00c5181548 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/default/.openapi-generator/VERSION +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/default/.openapi-generator/VERSION @@ -1 +1 @@ -3.0.1-SNAPSHOT \ No newline at end of file +3.0.2-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/default/.openapi-generator/VERSION b/samples/client/petstore/typescript-angular-v6-provided-in-root/default/.openapi-generator/VERSION index ad121e8340e0..1c00c5181548 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/default/.openapi-generator/VERSION +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/default/.openapi-generator/VERSION @@ -1 +1 @@ -3.0.1-SNAPSHOT \ No newline at end of file +3.0.2-SNAPSHOT \ No newline at end of file