[core] Move overwrite ownership to SupportingFile (#5036)

* [core] Move overwrite ownership to SupportingFile

Previously, there was a writeOptional method in DefaultCodegen which
allowed *Codegen instances to immediately write out a supporting file if
it did not exist. This would allow a codegen implementation to skip
user-facing options such as definitions in .openapi-codegen-ignore, the
"supportingFiles" system property, and support for the experimental
handlebars templating engine. While our implementation only modified the
supportingFiles list conditionally, it added confusion as it seemed to
imply that file writes were somewhat the responsibility of
DefaultCodgen (it's DefaultGenerator which handles file manipulation).

This commit moves the definition of whether a file supports overwriting
existing files into the SupportingFile type itself, allowing that
functionality to be determined at time-of-write rather than
time-of-definition. This would allow us, for example, to dump the list
of files which would be generated using a --dry-run option or similar.

This will be a breaking change for anyone who has extended
DefaultCodegen and called "writeOptional". The path to migrate is to add
the SupportingFile to the supportingFiles list and chain the method call
`.doNotOverwrite()` on the instance.

This has the added benefit of clarifying this behavior, considering the
write behavior wasn't previously "optional" writes but optionally
defining the list of supportingFiles based on the state of the file
system.

* [samples] Regenerated
This commit is contained in:
Jim Schubert 2020-01-29 18:26:39 -05:00 committed by GitHub
parent fa295aa2a8
commit 607f5a1c0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 231 additions and 166 deletions

View File

@ -4422,31 +4422,6 @@ public class DefaultCodegen implements CodegenConfig {
return tag;
}
/**
* Only write if the file doesn't exist
*
* @param outputFolder Output folder
* @param supportingFile Supporting file
*/
public void writeOptional(String outputFolder, SupportingFile supportingFile) {
String folder = "";
if (outputFolder != null && !"".equals(outputFolder)) {
folder += outputFolder + File.separator;
}
folder += supportingFile.folder;
if (!"".equals(folder)) {
folder += File.separator + supportingFile.destinationFilename;
} else {
folder = supportingFile.destinationFilename;
}
if (!new File(folder).exists()) {
supportingFiles.add(supportingFile);
} else {
LOGGER.info("Skipped overwriting " + supportingFile.destinationFilename + " as the file already exists in " + folder);
}
}
/**
* Set CodegenParameter boolean flag using CodegenProperty.
*

View File

@ -718,30 +718,35 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
continue;
}
if (ignoreProcessor.allowsFile(new File(outputFilename))) {
if (Arrays.stream(templatingEngine.getFileExtensions()).anyMatch(templateFile::endsWith)) {
String templateContent = templatingEngine.compileTemplate(this, bundle, support.templateFile);
writeToFile(outputFilename, templateContent);
File written = new File(outputFilename);
files.add(written);
if (config.isEnablePostProcessFile()) {
config.postProcessFile(written, "supporting-mustache");
}
File targetedFile = new File(outputFilename);
if (ignoreProcessor.allowsFile(targetedFile)) {
if (targetedFile.exists() && !support.canOverwrite) {
LOGGER.info("Skipped overwriting " + support.destinationFilename + " as the file already exists.");
} else {
InputStream in = null;
if (Arrays.stream(templatingEngine.getFileExtensions()).anyMatch(templateFile::endsWith)) {
String templateContent = templatingEngine.compileTemplate(this, bundle, support.templateFile);
writeToFile(outputFilename, templateContent);
File written = new File(outputFilename);
files.add(written);
if (config.isEnablePostProcessFile()) {
config.postProcessFile(written, "supporting-mustache");
}
} else {
InputStream in = null;
try {
in = new FileInputStream(templateFile);
} catch (Exception e) {
// continue
}
if (in == null) {
in = this.getClass().getClassLoader().getResourceAsStream(getCPResourcePath(templateFile));
}
File outputFile = writeInputStreamToFile(outputFilename, in, templateFile);
files.add(outputFile);
if (config.isEnablePostProcessFile()) {
config.postProcessFile(outputFile, "supporting-common");
try {
in = new FileInputStream(templateFile);
} catch (Exception e) {
// continue
}
if (in == null) {
in = this.getClass().getClassLoader().getResourceAsStream(getCPResourcePath(templateFile));
}
File outputFile = writeInputStreamToFile(outputFilename, in, templateFile);
files.add(outputFile);
if (config.isEnablePostProcessFile()) {
config.postProcessFile(outputFile, "supporting-common");
}
}
}
} else {

View File

@ -23,6 +23,7 @@ public class SupportingFile {
public String templateFile;
public String folder;
public String destinationFilename;
public boolean canOverwrite = true;
public SupportingFile(String templateFile, String destinationFilename) {
this(templateFile, "", destinationFilename);
@ -35,14 +36,8 @@ public class SupportingFile {
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("SupportingFile:").append("\n");
builder.append("\ttemplateFile: ").append(templateFile).append("\n");
builder.append("\tfolder: ").append(folder).append("\n");
builder.append("\tdestinationFilename: ").append(destinationFilename).append("\n");
return builder.toString();
public int hashCode() {
return Objects.hash(templateFile, folder, destinationFilename, canOverwrite);
}
@Override
@ -53,13 +48,32 @@ public class SupportingFile {
SupportingFile that = (SupportingFile) o;
return Objects.equals(templateFile, that.templateFile) &&
Objects.equals(folder, that.folder) &&
Objects.equals(destinationFilename, that.destinationFilename);
Objects.equals(folder, that.folder) &&
Objects.equals(destinationFilename, that.destinationFilename) &&
canOverwrite == that.canOverwrite;
}
@SuppressWarnings("StringBufferReplaceableByString")
@Override
public int hashCode() {
return Objects.hash(templateFile, folder, destinationFilename);
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("SupportingFile:").append("\n");
builder.append("\ttemplateFile: ").append(templateFile).append("\n");
builder.append("\tfolder: ").append(folder).append("\n");
builder.append("\tcanOverwrite: ").append(Boolean.valueOf(canOverwrite)).append("\n");
builder.append("\tdestinationFilename: ").append(destinationFilename).append("\n");
return builder.toString();
}
/**
* Identifies this instance as referring to a supporting file which should not overwrite a file of the same name.
*
* @return This object, for chaining.
*/
public SupportingFile doNotOverwrite() {
canOverwrite = false;
return this;
}
}

View File

@ -18,7 +18,6 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.lang3.StringUtils;
@ -315,7 +314,8 @@ public class ApexClientCodegen extends AbstractApexCodegen {
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
writeOptional(outputFolder, new SupportingFile("README_ant.mustache", "README.md"));
supportingFiles.add(new SupportingFile("README_ant.mustache", "README.md")
.doNotOverwrite());
}
@ -324,7 +324,8 @@ public class ApexClientCodegen extends AbstractApexCodegen {
supportingFiles.add(new SupportingFile("sfdx-project-scratch-def.json", sfdxConfigPath, "project-scratch-def.json"));
supportingFiles.add(new SupportingFile("sfdx-project.json.mustache", "sfdx-project.json"));
writeOptional(outputFolder, new SupportingFile("README_sfdx.mustache", "README.md"));
supportingFiles.add(new SupportingFile("README_sfdx.mustache", "README.md")
.doNotOverwrite());
}

View File

@ -173,7 +173,8 @@ public class ErlangServerCodegen extends DefaultCodegen implements CodegenConfig
supportingFiles.add(new SupportingFile("openapi.mustache", "", toPrivFilePath(this.openApiSpecName, "json")));
supportingFiles.add(new SupportingFile("default_logic_handler.mustache", "", toSourceFilePath("default_logic_handler", "erl")));
supportingFiles.add(new SupportingFile("logic_handler.mustache", "", toSourceFilePath("logic_handler", "erl")));
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")
.doNotOverwrite());
}
@Override

View File

@ -154,7 +154,8 @@ public class GoGinServerCodegen extends AbstractGoCodegen {
supportingFiles.add(new SupportingFile("main.mustache", "", "main.go"));
supportingFiles.add(new SupportingFile("Dockerfile.mustache", "", "Dockerfile"));
supportingFiles.add(new SupportingFile("routers.mustache", apiPath, "routers.go"));
writeOptional(outputFolder, new SupportingFile("README.mustache", apiPath, "README.md"));
supportingFiles.add(new SupportingFile("README.mustache", apiPath, "README.md")
.doNotOverwrite());
}
@Override

View File

@ -200,7 +200,8 @@ public class GoServerCodegen extends AbstractGoCodegen {
supportingFiles.add(new SupportingFile("routers.mustache", sourceFolder, "routers.go"));
supportingFiles.add(new SupportingFile("logger.mustache", sourceFolder, "logger.go"));
supportingFiles.add(new SupportingFile("api.mustache", sourceFolder, "api.go"));
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")
.doNotOverwrite());
}
@Override

View File

@ -112,7 +112,8 @@ public class JavaCXFClientCodegen extends AbstractJavaCodegen
supportingFiles.clear(); // Don't need extra files provided by AbstractJAX-RS & Java Codegen
writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml"));
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")
.doNotOverwrite());
}

View File

@ -183,41 +183,49 @@ public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen
supportingFiles.clear(); // Don't need extra files provided by AbstractJAX-RS & Java Codegen
writeOptional(outputFolder, new SupportingFile("server/pom.mustache", "", "pom.xml"));
supportingFiles.add(new SupportingFile("server/pom.mustache", "", "pom.xml")
.doNotOverwrite());
writeOptional(outputFolder,
new SupportingFile("server/openapi-generator-ignore.mustache", "", ".openapi-generator-ignore"));
supportingFiles.add(new SupportingFile("server/openapi-generator-ignore.mustache", "", ".openapi-generator-ignore")
.doNotOverwrite());
if (this.generateSpringApplication) {
writeOptional(outputFolder, new SupportingFile("server/readme.md", "", "readme.md"));
writeOptional(outputFolder, new SupportingFile("server/ApplicationContext.xml.mustache",
("src/main/resources"), "ApplicationContext.xml"));
writeOptional(outputFolder, new SupportingFile("server/web.mustache",
("src/main/webapp/WEB-INF"), "web.xml"));
writeOptional(outputFolder, new SupportingFile("server/context.xml.mustache",
("src/main/webapp/WEB-INF"), "context.xml"));
supportingFiles.add(new SupportingFile("server/readme.md", "", "readme.md")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("server/ApplicationContext.xml.mustache",
("src/main/resources"), "ApplicationContext.xml")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("server/web.mustache",
("src/main/webapp/WEB-INF"), "web.xml")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("server/context.xml.mustache",
("src/main/webapp/WEB-INF"), "context.xml")
.doNotOverwrite());
// Jboss
if (generateJbossDeploymentDescriptor) {
writeOptional(outputFolder, new SupportingFile("server/jboss-web.xml.mustache",
("src/main/webapp/WEB-INF"), "jboss-web.xml"));
supportingFiles.add(new SupportingFile("server/jboss-web.xml.mustache",
("src/main/webapp/WEB-INF"), "jboss-web.xml")
.doNotOverwrite());
}
// Spring Boot
if (this.generateSpringBootApplication) {
writeOptional(outputFolder, new SupportingFile("server/SpringBootApplication.mustache",
(testFolder + '/' + apiPackage).replace(".", "/"), "SpringBootApplication.java"));
writeOptional(outputFolder, new SupportingFile("server/application.properties.mustache",
(testResourcesFolder + '/'), "application.properties"));
supportingFiles.add(new SupportingFile("server/SpringBootApplication.mustache",
(testFolder + '/' + apiPackage).replace(".", "/"), "SpringBootApplication.java")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("server/application.properties.mustache",
(testResourcesFolder + '/'), "application.properties")
.doNotOverwrite());
}
}
if (this.generateNonSpringApplication) {
writeOptional(outputFolder, new SupportingFile("server/nonspring-web.mustache",
("src/main/webapp/WEB-INF"), "web.xml"));
supportingFiles.add(new SupportingFile("server/nonspring-web.mustache",
("src/main/webapp/WEB-INF"), "web.xml")
.doNotOverwrite());
}
}

View File

@ -276,13 +276,13 @@ public class JavaClientCodegen extends AbstractJavaCodegen
authFolder = (sourceFolder + '/' + invokerPackage + ".auth").replace(".", "/");
//Common files
writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml"));
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
writeOptional(outputFolder, new SupportingFile("build.gradle.mustache", "", "build.gradle"));
writeOptional(outputFolder, new SupportingFile("build.sbt.mustache", "", "build.sbt"));
writeOptional(outputFolder, new SupportingFile("settings.gradle.mustache", "", "settings.gradle"));
writeOptional(outputFolder, new SupportingFile("gradle.properties.mustache", "", "gradle.properties"));
writeOptional(outputFolder, new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml"));
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml").doNotOverwrite());
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md").doNotOverwrite());
supportingFiles.add(new SupportingFile("build.gradle.mustache", "", "build.gradle").doNotOverwrite());
supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt").doNotOverwrite());
supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle").doNotOverwrite());
supportingFiles.add(new SupportingFile("gradle.properties.mustache", "", "gradle.properties").doNotOverwrite());
supportingFiles.add(new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml").doNotOverwrite());
supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml"));
supportingFiles.add(new SupportingFile("ApiClient.mustache", invokerFolder, "ApiClient.java"));
if (!(RESTTEMPLATE.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()) || NATIVE.equals(getLibrary()) || MICROPROFILE.equals(getLibrary()))) {

View File

@ -92,10 +92,14 @@ public class JavaInflectorServerCodegen extends AbstractJavaCodegen {
public void processOpts() {
super.processOpts();
writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml"));
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
writeOptional(outputFolder, new SupportingFile("web.mustache", "src/main/webapp/WEB-INF", "web.xml"));
writeOptional(outputFolder, new SupportingFile("inflector.mustache", "", "inflector.yaml"));
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("web.mustache", "src/main/webapp/WEB-INF", "web.xml")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("inflector.mustache", "", "inflector.yaml")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("openapi.mustache",
"src/main/openapi",
"openapi.yaml")

View File

@ -73,18 +73,19 @@ public class JavaJAXRSCXFCDIServerCodegen extends JavaJAXRSSpecServerCodegen imp
supportingFiles.clear(); // Don't need extra files provided by AbstractJAX-RS & Java Codegen
// writeOptional means these files are only written if they don't already exist
// POM
writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml"));
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")
.doNotOverwrite());
// RestApplication into src/main/java
writeOptional(outputFolder, new SupportingFile("RestApplication.mustache",
(implFolder + '/' + invokerPackage).replace(".", "/"), "RestApplication.java"));
supportingFiles.add(new SupportingFile("RestApplication.mustache",
(implFolder + '/' + invokerPackage).replace(".", "/"), "RestApplication.java")
.doNotOverwrite());
// Make CDI work in containers with implicit archive scanning disabled
writeOptional(outputFolder, new SupportingFile("beans.mustache",
"src/main/webapp/WEB-INF", "beans.xml"));
supportingFiles.add(new SupportingFile("beans.mustache",
"src/main/webapp/WEB-INF", "beans.xml")
.doNotOverwrite());
}
@Override

View File

@ -153,13 +153,16 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
super.processOpts();
supportingFiles.clear(); // Don't need extra files provided by AbstractJAX-RS & Java Codegen
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")
.doNotOverwrite());
if (generatePom) {
writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml"));
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")
.doNotOverwrite());
}
if (!interfaceOnly) {
writeOptional(outputFolder, new SupportingFile("RestApplication.mustache",
(sourceFolder + '/' + invokerPackage).replace(".", "/"), "RestApplication.java"));
supportingFiles.add(new SupportingFile("RestApplication.mustache",
(sourceFolder + '/' + invokerPackage).replace(".", "/"), "RestApplication.java")
.doNotOverwrite());
}
if(StringUtils.isNotEmpty(openApiSpecFileLocation)) {
@ -177,23 +180,32 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
}
if(QUARKUS_LIBRARY.equals(library)) {
writeOptional(outputFolder, new SupportingFile("application.properties.mustache", "src/main/resources", "application.properties"));
writeOptional(outputFolder, new SupportingFile("Dockerfile.jvm.mustache", "src/main/docker", "Dockerfile.jvm"));
writeOptional(outputFolder, new SupportingFile("Dockerfile.native.mustache", "src/main/docker", "Dockerfile.native"));
writeOptional(outputFolder, new SupportingFile("dockerignore.mustache", "", ".dockerignore"));
supportingFiles.add(new SupportingFile("application.properties.mustache", "src/main/resources", "application.properties")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("Dockerfile.jvm.mustache", "src/main/docker", "Dockerfile.jvm")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("Dockerfile.native.mustache", "src/main/docker", "Dockerfile.native")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("dockerignore.mustache", "", ".dockerignore")
.doNotOverwrite());
} else if(OPEN_LIBERTY_LIBRARY.equals(library)) {
writeOptional(outputFolder, new SupportingFile("server.xml.mustache", "src/main/liberty/config", "server.xml"));
writeOptional(outputFolder, new SupportingFile("beans.xml.mustache", "src/main/webapp/META-INF", "beans.xml"));
writeOptional(outputFolder, new SupportingFile("MANIFEST.MF.mustache", "src/main/webapp/META-INF", "MANIFEST.MF"));
writeOptional(outputFolder, new SupportingFile("microprofile-config.properties.mustache", "src/main/webapp/META-INF", "microprofile-config.properties"));
writeOptional(outputFolder, new SupportingFile("ibm-web-ext.xml.mustache", "src/main/webapp/WEB-INF", "ibm-web-ext.xml"));
supportingFiles.add(new SupportingFile("server.xml.mustache", "src/main/liberty/config", "server.xml")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("beans.xml.mustache", "src/main/webapp/META-INF", "beans.xml")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("MANIFEST.MF.mustache", "src/main/webapp/META-INF", "MANIFEST.MF")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("microprofile-config.properties.mustache", "src/main/webapp/META-INF", "microprofile-config.properties")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("ibm-web-ext.xml.mustache", "src/main/webapp/WEB-INF", "ibm-web-ext.xml")
.doNotOverwrite());
} else if(HELIDON_LIBRARY.equals(library)) {
writeOptional(outputFolder, new SupportingFile("logging.properties.mustache", "src/main/resources", "logging.properties"));
writeOptional(outputFolder, new SupportingFile("microprofile-config.properties.mustache", "src/main/resources/META-INF", "microprofile-config.properties"));
writeOptional(outputFolder, new SupportingFile("beans.xml.mustache", "src/main/webapp/META-INF", "beans.xml"));
supportingFiles.add(new SupportingFile("logging.properties.mustache", "src/main/resources", "logging.properties")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("microprofile-config.properties.mustache", "src/main/resources/META-INF", "microprofile-config.properties")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("beans.xml.mustache", "src/main/webapp/META-INF", "beans.xml")
.doNotOverwrite());
}
}

View File

@ -122,16 +122,20 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen {
supportingFiles.add(new SupportingFile("LocalDateProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "LocalDateProvider.java"));
}
writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml"));
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("ApiException.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiException.java"));
supportingFiles.add(new SupportingFile("ApiOriginFilter.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiOriginFilter.java"));
supportingFiles.add(new SupportingFile("ApiResponseMessage.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiResponseMessage.java"));
supportingFiles.add(new SupportingFile("NotFoundException.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "NotFoundException.java"));
supportingFiles.add(new SupportingFile("jacksonJsonProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JacksonJsonProvider.java"));
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "RFC3339DateFormat.java"));
writeOptional(outputFolder, new SupportingFile("bootstrap.mustache", (implFolder + '/' + apiPackage).replace(".", "/"), "Bootstrap.java"));
writeOptional(outputFolder, new SupportingFile("web.mustache", ("src/main/webapp/WEB-INF"), "web.xml"));
supportingFiles.add(new SupportingFile("bootstrap.mustache", (implFolder + '/' + apiPackage).replace(".", "/"), "Bootstrap.java")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("web.mustache", ("src/main/webapp/WEB-INF"), "web.xml")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("StringUtil.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "StringUtil.java"));
}

View File

@ -108,16 +108,18 @@ public class JavaMSF4JServerCodegen extends AbstractJavaJAXRSServerCodegen {
supportingFiles.add(new SupportingFile("LocalDateProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "LocalDateProvider.java"));
}
writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml"));
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("ApiException.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiException.java"));
supportingFiles.add(new SupportingFile("ApiOriginFilter.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiOriginFilter.java"));
supportingFiles.add(new SupportingFile("ApiResponseMessage.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiResponseMessage.java"));
supportingFiles.add(new SupportingFile("NotFoundException.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "NotFoundException.java"));
supportingFiles.add(new SupportingFile("jacksonJsonProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JacksonJsonProvider.java"));
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "RFC3339DateFormat.java"));
//writeOptional(outputFolder, new SupportingFile("bootstrap.mustache", (implFolder + '/' + apiPackage).replace(".", "/"), "Bootstrap.java"));
//writeOptional(outputFolder, new SupportingFile("web.mustache", ("src/main/webapp/WEB-INF"), "web.xml"));
// supportingFiles.add(new SupportingFile("bootstrap.mustache", (implFolder + '/' + apiPackage).replace(".", "/"), "Bootstrap.java").doNotOverwrite());
// supportingFiles.add(new SupportingFile("web.mustache", ("src/main/webapp/WEB-INF"), "web.xml").doNotOverwrite());
supportingFiles.add(new SupportingFile("StringUtil.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "StringUtil.java"));
supportingFiles.add(new SupportingFile("Application.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "Application.java"));
}

View File

@ -99,19 +99,26 @@ public class JavaResteasyEapServerCodegen extends AbstractJavaJAXRSServerCodegen
writePropertyBack(USE_SWAGGER_FEATURE, useSwaggerFeature);
writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml"));
writeOptional(outputFolder, new SupportingFile("gradle.mustache", "", "build.gradle"));
writeOptional(outputFolder, new SupportingFile("settingsGradle.mustache", "", "settings.gradle"));
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
writeOptional(outputFolder, new SupportingFile("web.mustache", ("src/main/webapp/WEB-INF"), "web.xml"));
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("gradle.mustache", "", "build.gradle")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("settingsGradle.mustache", "", "settings.gradle")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("web.mustache", ("src/main/webapp/WEB-INF"), "web.xml")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("JacksonConfig.mustache", (projectFolder + File.separator + "java" + '/' + invokerPackage).replace(".", "/"), "JacksonConfig.java"));
if (generateJbossDeploymentDescriptor) {
writeOptional(outputFolder, new SupportingFile("jboss-web.mustache", ("src/main/webapp/WEB-INF"), "jboss-web.xml"));
supportingFiles.add(new SupportingFile("jboss-web.mustache", ("src/main/webapp/WEB-INF"), "jboss-web.xml")
.doNotOverwrite());
}
writeOptional(outputFolder, new SupportingFile("RestApplication.mustache", (projectFolder + File.separator + "java" + '/' + invokerPackage).replace(".", "/"), "RestApplication.java"));
supportingFiles.add(new SupportingFile("RestApplication.mustache", (projectFolder + File.separator + "java" + '/' + invokerPackage).replace(".", "/"), "RestApplication.java")
.doNotOverwrite());
}

View File

@ -83,10 +83,15 @@ public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen im
this.setGenerateJbossDeploymentDescriptor(generateJbossDeploymentDescriptorProp);
}
writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml"));
writeOptional(outputFolder, new SupportingFile("gradle.mustache", "", "build.gradle"));
writeOptional(outputFolder, new SupportingFile("settingsGradle.mustache", "", "settings.gradle"));
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("gradle.mustache", "", "build.gradle")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("settingsGradle.mustache", "", "settings.gradle")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("ApiException.mustache",
(sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiException.java"));
supportingFiles.add(new SupportingFile("ApiOriginFilter.mustache",
@ -95,16 +100,19 @@ public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen im
(sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiResponseMessage.java"));
supportingFiles.add(new SupportingFile("NotFoundException.mustache",
(sourceFolder + '/' + apiPackage).replace(".", "/"), "NotFoundException.java"));
writeOptional(outputFolder, new SupportingFile("web.mustache",
("src/main/webapp/WEB-INF"), "web.xml"));
supportingFiles.add(new SupportingFile("web.mustache",
("src/main/webapp/WEB-INF"), "web.xml")
.doNotOverwrite());
if (generateJbossDeploymentDescriptor) {
writeOptional(outputFolder, new SupportingFile("jboss-web.mustache",
("src/main/webapp/WEB-INF"), "jboss-web.xml"));
supportingFiles.add(new SupportingFile("jboss-web.mustache",
("src/main/webapp/WEB-INF"), "jboss-web.xml")
.doNotOverwrite());
}
writeOptional(outputFolder, new SupportingFile("RestApplication.mustache",
(sourceFolder + '/' + invokerPackage).replace(".", "/"), "RestApplication.java"));
supportingFiles.add(new SupportingFile("RestApplication.mustache",
(sourceFolder + '/' + invokerPackage).replace(".", "/"), "RestApplication.java")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("StringUtil.mustache",
(sourceFolder + '/' + invokerPackage).replace(".", "/"), "StringUtil.java"));
supportingFiles.add(new SupportingFile("JacksonConfig.mustache",

View File

@ -101,8 +101,10 @@ public class JavaUndertowServerCodegen extends AbstractJavaCodegen {
apiTemplateFiles.remove("api.mustache");
writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml"));
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")
.doNotOverwrite());
// keep the yaml in config folder for framework validation.
supportingFiles.add(new SupportingFile("openapi.mustache", ("src.main.resources.config").replace(".", java.io.File.separator), "openapi.json"));

View File

@ -157,10 +157,13 @@ public class JavaVertXServerCodegen extends AbstractJavaCodegen {
sourceFolder + File.separator + rootPackage.replace(".", File.separator),
"MainApiException.java"));
writeOptional(outputFolder, new SupportingFile("vertx-default-jul-logging.mustache",
resourceFolder, "vertx-default-jul-logging.properties"));
writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml"));
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("vertx-default-jul-logging.mustache",
resourceFolder, "vertx-default-jul-logging.properties")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")
.doNotOverwrite());
}
@Override

View File

@ -113,7 +113,8 @@ public class JavaVertXWebServerCodegen extends AbstractJavaCodegen {
supportingFiles.add(new SupportingFile("supportFiles/ParameterCast.mustache", sourcePackageFolder, "ParameterCast.java"));
supportingFiles.add(new SupportingFile("supportFiles/pom.mustache", "", "pom.xml"));
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")
.doNotOverwrite());
}
@Override

View File

@ -118,8 +118,10 @@ public class NodeJSExpressServerCodegen extends DefaultCodegen implements Codege
supportingFiles.add(new SupportingFile("services" + File.separator + "Service.mustache", "services", "Service.js"));
// do not overwrite if the file is already present
writeOptional(outputFolder, new SupportingFile("package.mustache", "", "package.json"));
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")
.doNotOverwrite());
cliOptions.add(new CliOption(SERVER_PORT,
"TCP port to listen on."));

View File

@ -362,12 +362,16 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
"openapi.yaml")
);
if (getGoogleCloudFunctions()) {
writeOptional(outputFolder, new SupportingFile("index-gcf.mustache", "", "index.js"));
supportingFiles.add(new SupportingFile("index-gcf.mustache", "", "index.js")
.doNotOverwrite());
} else {
writeOptional(outputFolder, new SupportingFile("index.mustache", "", "index.js"));
supportingFiles.add(new SupportingFile("index.mustache", "", "index.js")
.doNotOverwrite());
}
writeOptional(outputFolder, new SupportingFile("package.mustache", "", "package.json"));
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")
.doNotOverwrite());
if (GlobalSettings.getProperty("noservice") == null) {
apiTemplateFiles.put(
"service.mustache", // the template to use

View File

@ -268,10 +268,14 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
}
// test files should not be overwritten
writeOptional(outputFolder, new SupportingFile("rspec.mustache", "", ".rspec"));
writeOptional(outputFolder, new SupportingFile("spec_helper.mustache", specFolder, "spec_helper.rb"));
writeOptional(outputFolder, new SupportingFile("configuration_spec.mustache", specFolder, "configuration_spec.rb"));
writeOptional(outputFolder, new SupportingFile("api_client_spec.mustache", specFolder, "api_client_spec.rb"));
supportingFiles.add(new SupportingFile("rspec.mustache", "", ".rspec")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("spec_helper.mustache", specFolder, "spec_helper.rb")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("configuration_spec.mustache", specFolder, "configuration_spec.rb")
.doNotOverwrite());
supportingFiles.add(new SupportingFile("api_client_spec.mustache", specFolder, "api_client_spec.rb")
.doNotOverwrite());
}
@Override

View File

@ -237,7 +237,8 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
supportingFiles.add(new SupportingFile("example-ca.pem", "examples", "ca.pem"));
supportingFiles.add(new SupportingFile("example-server-chain.pem", "examples", "server-chain.pem"));
supportingFiles.add(new SupportingFile("example-server-key.pem", "examples", "server-key.pem"));
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")
.doNotOverwrite());
}
@Override

View File

@ -1 +1 @@
5.0.0-SNAPSHOT
5.0.0-SNAPSHOT

View File

@ -0,0 +1,3 @@
<manifest package="org.openapitools.client" xmlns:android="http://schemas.android.com/apk/res/android">
<application />
</manifest>