forked from loafle/openapi-generator-original
[feature #1255] Start of an implementation of model name prefix + suffix.
This is just the implementation in DefaultCodegen and some configurator stuff, the connection to command line arguments is still missing.
This commit is contained in:
@@ -82,4 +82,9 @@ public class CodegenConstants {
|
||||
|
||||
public static enum MODEL_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case, original}
|
||||
|
||||
public static final String MODEL_NAME_PREFIX = "modelNamePrefix";
|
||||
public static final String MODEL_NAME_PREFIX_DESC = "Prefix that will be prepended to all model names. Default is the empty string.";
|
||||
|
||||
public static final String MODEL_NAME_SUFFIX = "modelNameSuffix";
|
||||
public static final String MODEL_NAME_SUFFIX_DESC = "Suffix that will be appended to all model names. Default is the empty string.";
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ public class DefaultCodegen {
|
||||
protected Set<String> languageSpecificPrimitives = new HashSet<String>();
|
||||
protected Map<String, String> importMapping = new HashMap<String, String>();
|
||||
protected String modelPackage = "", apiPackage = "", fileSuffix;
|
||||
protected String modelNamePrefix = "", modelNameSuffix = "";
|
||||
protected String testPackage = "";
|
||||
protected Map<String, String> apiTemplateFiles = new HashMap<String, String>();
|
||||
protected Map<String, String> modelTemplateFiles = new HashMap<String, String>();
|
||||
@@ -826,8 +827,8 @@ public class DefaultCodegen {
|
||||
* @param name the name of the model
|
||||
* @return capitalized model name
|
||||
*/
|
||||
public String toModelName(String name) {
|
||||
return initialCaps(name);
|
||||
public String toModelName(final String name) {
|
||||
return initialCaps(modelNamePrefix + name + modelNameSuffix);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,6 +48,8 @@ public class CodegenConfigurator {
|
||||
private String apiPackage;
|
||||
private String modelPackage;
|
||||
private String invokerPackage;
|
||||
private String modelNamePrefix;
|
||||
private String modelNameSuffix;
|
||||
private String groupId;
|
||||
private String artifactId;
|
||||
private String artifactVersion;
|
||||
@@ -97,6 +99,24 @@ public class CodegenConfigurator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getModelNamePrefix() {
|
||||
return modelNamePrefix;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setModelNamePrefix(String prefix) {
|
||||
this.modelNamePrefix = prefix;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getModelNameSuffix() {
|
||||
return modelNameSuffix;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setModelNameSuffix(String suffix) {
|
||||
this.modelNameSuffix = suffix;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isVerbose() {
|
||||
return verbose;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user