diff --git a/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java b/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java index f898c218d3..d3bc1a0153 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java +++ b/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java @@ -141,10 +141,11 @@ public abstract class DefaultCodegenConfig implements CodegenConfig { protected String templateVersion; protected String embeddedTemplateDir; protected String commonTemplateDir = "_common"; - protected Map additionalProperties = new HashMap(); + protected Map additionalProperties = new HashMap<>(); protected Map vendorExtensions = new HashMap(); - protected List supportingFiles = new ArrayList(); - protected List cliOptions = new ArrayList(); + protected List supportingFiles = new ArrayList<>(); + protected List configFiles = new ArrayList<>(); + protected List cliOptions = new ArrayList<>(); protected List languageArguments; protected boolean skipOverwrite; protected boolean removeOperationIdPrefix; @@ -664,6 +665,10 @@ public List supportingFiles() { return supportingFiles; } + public List configFiles() { + return configFiles; + } + public String outputFolder() { return outputFolder; } @@ -3807,13 +3812,16 @@ protected String getOptionValue(String optionName) { return codegenArgumentOptional.get().getValue(); } + public void writeOptional(String outputFolder, SupportingFile supportingFile) { + writeOptional(outputFolder, supportingFile, false); + } /** * Only write if the file doesn't exist * * @param outputFolder Output folder * @param supportingFile Supporting file */ - public void writeOptional(String outputFolder, SupportingFile supportingFile) { + public void writeOptional(String outputFolder, SupportingFile supportingFile, boolean configFile) { String folder = ""; if(outputFolder != null && !"".equals(outputFolder)) { @@ -3826,8 +3834,9 @@ public void writeOptional(String outputFolder, SupportingFile supportingFile) { else { folder = supportingFile.destinationFilename; } + List targetFiles = configFile ? this.configFiles : this.supportingFiles; if(!new File(folder).exists()) { - supportingFiles.add(supportingFile); + targetFiles.add(supportingFile); } else { LOGGER.info("Skipped overwriting " + supportingFile.destinationFilename + " as the file already exists in " + folder); }