forked from loafle/openapi-generator-original
[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:
committed by
Paul Ebermann
parent
98c5e70f7c
commit
a6f3914a92
@@ -108,6 +108,14 @@ public class DefaultCodegen {
|
||||
this.setEnsureUniqueParams(Boolean.valueOf(additionalProperties
|
||||
.get(CodegenConstants.ENSURE_UNIQUE_PARAMS).toString()));
|
||||
}
|
||||
|
||||
if(additionalProperties.containsKey(CodegenConstants.MODEL_NAME_PREFIX)){
|
||||
this.setModelNamePrefix((String) additionalProperties.get(CodegenConstants.MODEL_NAME_PREFIX));
|
||||
}
|
||||
|
||||
if(additionalProperties.containsKey(CodegenConstants.MODEL_NAME_SUFFIX)){
|
||||
this.setModelNameSuffix((String) additionalProperties.get(CodegenConstants.MODEL_NAME_SUFFIX));
|
||||
}
|
||||
}
|
||||
|
||||
// override with any special post-processing for all models
|
||||
@@ -284,6 +292,14 @@ public class DefaultCodegen {
|
||||
this.modelPackage = modelPackage;
|
||||
}
|
||||
|
||||
public void setModelNamePrefix(String modelNamePrefix){
|
||||
this.modelNamePrefix = modelNamePrefix;
|
||||
}
|
||||
|
||||
public void setModelNameSuffix(String modelNameSuffix){
|
||||
this.modelNameSuffix = modelNameSuffix;
|
||||
}
|
||||
|
||||
public void setApiPackage(String apiPackage) {
|
||||
this.apiPackage = apiPackage;
|
||||
}
|
||||
|
||||
@@ -320,6 +320,8 @@ public class CodegenConfigurator {
|
||||
checkAndSetAdditionalProperty(artifactId, CodegenConstants.ARTIFACT_ID);
|
||||
checkAndSetAdditionalProperty(artifactVersion, CodegenConstants.ARTIFACT_VERSION);
|
||||
checkAndSetAdditionalProperty(templateDir, toAbsolutePathStr(templateDir), CodegenConstants.TEMPLATE_DIR);
|
||||
checkAndSetAdditionalProperty(modelNamePrefix, CodegenConstants.MODEL_NAME_PREFIX);
|
||||
checkAndSetAdditionalProperty(modelNameSuffix, CodegenConstants.MODEL_NAME_SUFFIX);
|
||||
|
||||
handleDynamicProperties(config);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user