Skip to content

Commit 4d4fd87

Browse files
committed
refs #1319 - add configFiles list
1 parent 63714c6 commit 4d4fd87

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,11 @@ public abstract class DefaultCodegenConfig implements CodegenConfig {
141141
protected String templateVersion;
142142
protected String embeddedTemplateDir;
143143
protected String commonTemplateDir = "_common";
144-
protected Map<String, Object> additionalProperties = new HashMap<String, Object>();
144+
protected Map<String, Object> additionalProperties = new HashMap<>();
145145
protected Map<String, Object> vendorExtensions = new HashMap<String, Object>();
146-
protected List<SupportingFile> supportingFiles = new ArrayList<SupportingFile>();
147-
protected List<CliOption> cliOptions = new ArrayList<CliOption>();
146+
protected List<SupportingFile> supportingFiles = new ArrayList<>();
147+
protected List<SupportingFile> configFiles = new ArrayList<>();
148+
protected List<CliOption> cliOptions = new ArrayList<>();
148149
protected List<CodegenArgument> languageArguments;
149150
protected boolean skipOverwrite;
150151
protected boolean removeOperationIdPrefix;
@@ -664,6 +665,10 @@ public List<SupportingFile> supportingFiles() {
664665
return supportingFiles;
665666
}
666667

668+
public List<SupportingFile> configFiles() {
669+
return configFiles;
670+
}
671+
667672
public String outputFolder() {
668673
return outputFolder;
669674
}
@@ -3807,13 +3812,16 @@ protected String getOptionValue(String optionName) {
38073812
return codegenArgumentOptional.get().getValue();
38083813
}
38093814

3815+
public void writeOptional(String outputFolder, SupportingFile supportingFile) {
3816+
writeOptional(outputFolder, supportingFile, false);
3817+
}
38103818
/**
38113819
* Only write if the file doesn't exist
38123820
*
38133821
* @param outputFolder Output folder
38143822
* @param supportingFile Supporting file
38153823
*/
3816-
public void writeOptional(String outputFolder, SupportingFile supportingFile) {
3824+
public void writeOptional(String outputFolder, SupportingFile supportingFile, boolean configFile) {
38173825
String folder = "";
38183826

38193827
if(outputFolder != null && !"".equals(outputFolder)) {
@@ -3826,8 +3834,9 @@ public void writeOptional(String outputFolder, SupportingFile supportingFile) {
38263834
else {
38273835
folder = supportingFile.destinationFilename;
38283836
}
3837+
List<SupportingFile> targetFiles = configFile ? this.configFiles : this.supportingFiles;
38293838
if(!new File(folder).exists()) {
3830-
supportingFiles.add(supportingFile);
3839+
targetFiles.add(supportingFile);
38313840
} else {
38323841
LOGGER.info("Skipped overwriting " + supportingFile.destinationFilename + " as the file already exists in " + folder);
38333842
}

0 commit comments

Comments
 (0)