Skip to content

Commit

Permalink
Merge pull request #689 from swagger-api/issue-688
Browse files Browse the repository at this point in the history
added option to skip support files on micronaut generator
  • Loading branch information
HugoMario authored May 22, 2020
2 parents 76ea8a8 + 1e888cd commit 614cc91
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class MicronautCodegen extends AbstractJavaCodegen implements BeanValidat
private static final String BASE_PACKAGE = "basePackage";
private static final String USE_TAGS = "useTags";
private static final String IMPLICIT_HEADERS = "implicitHeaders";
private static final String SKIP_SUPPORT_FILES = "skipSupportFiles";

private String title = "swagger-petstore";
private String configPackage = "io.swagger.configuration";
Expand Down Expand Up @@ -66,6 +67,7 @@ private void init() {
cliOptions.add(new CliOption(TITLE, "server title name or client service name"));
cliOptions.add(new CliOption(CONFIG_PACKAGE, "configuration package for generated code"));
cliOptions.add(new CliOption(BASE_PACKAGE, "base package (invokerPackage) for generated code"));
cliOptions.add(new CliOption(SKIP_SUPPORT_FILES, "skip support files such as pom.xml, mvnw, etc from code generation."));
cliOptions.add(CliOption.newBoolean(USE_TAGS, "use tags for creating interface and controller classnames"));
cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations"));
cliOptions.add(CliOption.newBoolean(IMPLICIT_HEADERS, "Use of @ApiImplicitParams for headers."));
Expand Down Expand Up @@ -152,6 +154,11 @@ public void processOpts() {
this.setUseOptional(convertPropertyToBoolean(USE_OPTIONAL));
}

boolean skipSupportFiles = false;
if (additionalProperties.containsKey(SKIP_SUPPORT_FILES)) {
skipSupportFiles = Boolean.valueOf(additionalProperties.get(SKIP_SUPPORT_FILES).toString());
}

if (useBeanValidation) {
writePropertyBack(USE_BEANVALIDATION, useBeanValidation);
}
Expand All @@ -164,14 +171,15 @@ public void processOpts() {
writePropertyBack(USE_OPTIONAL, useOptional);
}

supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("mvnw", "", "mvnw"));
supportingFiles.add(new SupportingFile("mvnw.cmd", "", "mvnw.cmd"));
supportingFiles.add(new SupportingFile("unsupportedOperationExceptionHandler.mustache",
if (!skipSupportFiles) {
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("mvnw", "", "mvnw"));
supportingFiles.add(new SupportingFile("mvnw.cmd", "", "mvnw.cmd"));
supportingFiles.add(new SupportingFile("unsupportedOperationExceptionHandler.mustache",
(sourceFolder + File.separator + configPackage).replace(".", File.separator), "UnsupportedOperationExceptionHandler.java"));
supportingFiles.add(new SupportingFile("mainApplication.mustache", (sourceFolder + File.separator).replace(".", File.separator), "MainApplication.java"));

supportingFiles.add(new SupportingFile("mainApplication.mustache", (sourceFolder + File.separator).replace(".", File.separator), "MainApplication.java"));
}
addHandlebarsLambdas(additionalProperties);
}

Expand Down

0 comments on commit 614cc91

Please sign in to comment.