[feature #1255] prefix and suffix for model names.

This implements the command line arguments `--model-name-prefix` and `--model-name-suffix`
for all languages which do not override `DefaultCodegen.toModelName()`.
This fixes most of swagger-api/swagger-codegen#1255.

Connection to the maven plugin works with additional-properties, a more explicit
parameter waits for swagger-api/swagger-codegen#2168.
This commit is contained in:
Jim Schubert
2016-02-18 13:07:42 -05:00
committed by Paul Ebermann
parent 98c5e70f7c
commit a6f3914a92
3 changed files with 32 additions and 0 deletions

View File

@@ -73,6 +73,12 @@ public class Generate implements Runnable {
@Option(name = {"--model-package"}, title = "model package", description = CodegenConstants.MODEL_PACKAGE_DESC)
private String modelPackage;
@Option(name = {"--model-name-prefix"}, title = "model name prefix", description = CodegenConstants.MODEL_NAME_PREFIX_DESC)
private String modelNamePrefix;
@Option(name = {"--model-name-suffix"}, title = "model name suffix", description = CodegenConstants.MODEL_NAME_SUFFIX_DESC)
private String modelNameSuffix;
@Option(name = {"--instantiation-types"}, title = "instantiation types", description = "sets instantiation type mappings in the format of type=instantiatedType,type=instantiatedType." +
"For example (in Java): array=ArrayList,map=HashMap. In other words array types will get instantiated as ArrayList in generated code.")
private String instantiationTypes;
@@ -156,6 +162,14 @@ public class Generate implements Runnable {
configurator.setModelPackage(modelPackage);
}
if(isNotEmpty(modelNamePrefix)){
configurator.setModelNamePrefix(modelNamePrefix);
}
if(isNotEmpty(modelNameSuffix)){
configurator.setModelNameSuffix(modelNameSuffix);
}
if(isNotEmpty(invokerPackage)) {
configurator.setInvokerPackage(invokerPackage);
}