Skip to content

Commit cf02d17

Browse files
authored
Merge pull request #3289 from d0x/Make_Pre_and_Suffix_Available
[MAVEN] #3284: Made modelNamePrefix and -Suffix available through maven
2 parents 6e561e1 + 8533ca4 commit cf02d17

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

modules/swagger-codegen-maven-plugin/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ mvn clean compile
4545
- `modelPackage` - the package to use for generated model objects/classes
4646
- `apiPackage` - the package to use for generated api objects/classes
4747
- `invokerPackage` - the package to use for the generated invoker objects
48+
- `modelNamePrefix` and `modelNameSuffix` - Sets the pre- or suffix for model classes and enums.
4849
- `configOptions` - a map of language-specific parameters (see below)
4950
- `configHelp` - dumps the configuration help for the specified library (generates no sources)
5051

modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
import io.swagger.codegen.CodegenConfig;
2222
import io.swagger.codegen.DefaultGenerator;
2323
import io.swagger.codegen.config.CodegenConfigurator;
24-
import io.swagger.models.Swagger;
25-
import io.swagger.parser.SwaggerParser;
2624
import org.apache.maven.plugin.AbstractMojo;
2725
import org.apache.maven.plugin.MojoExecutionException;
2826
import org.apache.maven.plugins.annotations.LifecyclePhase;
@@ -32,9 +30,7 @@
3230

3331
import java.io.File;
3432
import java.util.HashMap;
35-
import java.util.HashSet;
3633
import java.util.Map;
37-
import java.util.Set;
3834

3935
import static io.swagger.codegen.config.CodegenConfiguratorUtils.*;
4036
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
@@ -135,6 +131,18 @@ public class CodeGenMojo extends AbstractMojo {
135131
@Parameter(name = "library", required = false)
136132
private String library;
137133

134+
/**
135+
* Sets the prefix for model enums and classes
136+
*/
137+
@Parameter(name = "modelNamePrefix", required = false)
138+
private String modelNamePrefix;
139+
140+
/**
141+
* Sets the suffix for model enums and classes
142+
*/
143+
@Parameter(name = "modelNameSuffix", required = false)
144+
private String modelNameSuffix;
145+
138146
/**
139147
* A map of language-specific parameters as passed with the -c option to the command line
140148
*/
@@ -217,6 +225,14 @@ public void execute() throws MojoExecutionException {
217225
configurator.setLibrary(library);
218226
}
219227

228+
if(isNotEmpty(modelNamePrefix)) {
229+
configurator.setModelNamePrefix(modelNamePrefix);
230+
}
231+
232+
if(isNotEmpty(modelNameSuffix)) {
233+
configurator.setModelNameSuffix(modelNameSuffix);
234+
}
235+
220236
if (null != templateDirectory) {
221237
configurator.setTemplateDir(templateDirectory.getAbsolutePath());
222238
}

0 commit comments

Comments
 (0)