#3284: Made modelNamePrefix and -Suffix available through maven

This commit is contained in:
christian 2016-07-04 19:51:38 +02:00
parent 6d6cfbfd5d
commit 0ada53435c
2 changed files with 21 additions and 4 deletions

View File

@ -45,6 +45,7 @@ mvn clean compile
- `modelPackage` - the package to use for generated model objects/classes
- `apiPackage` - the package to use for generated api objects/classes
- `invokerPackage` - the package to use for the generated invoker objects
- `modelNamePrefix` and `modelNameSuffix` - Sets the pre- or suffix for model classes and enums.
- `configOptions` - a map of language-specific parameters (see below)
- `configHelp` - dumps the configuration help for the specified library (generates no sources)

View File

@ -21,8 +21,6 @@ import io.swagger.codegen.ClientOptInput;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.DefaultGenerator;
import io.swagger.codegen.config.CodegenConfigurator;
import io.swagger.models.Swagger;
import io.swagger.parser.SwaggerParser;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
@ -32,9 +30,7 @@ import org.apache.maven.project.MavenProject;
import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import static io.swagger.codegen.config.CodegenConfiguratorUtils.*;
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
@ -135,6 +131,18 @@ public class CodeGenMojo extends AbstractMojo {
@Parameter(name = "library", required = false)
private String library;
/**
* Sets the prefix for model enums and classes
*/
@Parameter(name = "modelNamePrefix", required = false)
private String modelNamePrefix;
/**
* Sets the suffix for model enums and classes
*/
@Parameter(name = "modelNameSuffix", required = false)
private String modelNameSuffix;
/**
* A map of language-specific parameters as passed with the -c option to the command line
*/
@ -217,6 +225,14 @@ public class CodeGenMojo extends AbstractMojo {
configurator.setLibrary(library);
}
if(isNotEmpty(modelNamePrefix)) {
configurator.setModelNamePrefix(modelNamePrefix);
}
if(isNotEmpty(modelNameSuffix)) {
configurator.setModelNamePrefix(modelNameSuffix);
}
if (null != templateDirectory) {
configurator.setTemplateDir(templateDirectory.getAbsolutePath());
}