From 81df4da3baf2f5b590cb2a3c2c4608b5b0d08045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Gr=C3=B6ber?= Date: Thu, 23 Jan 2025 11:58:07 +0100 Subject: [PATCH 1/2] Update DefaultGenerator.java to implement SupportingFiles.doNotOverwrite option I could not see any usage of doNotOverwrite/isCanOverwrite of SupportingFile class --- .../main/java/org/openapitools/codegen/DefaultGenerator.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java index 0e377c2bd656..64e5263ef4f3 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java @@ -1098,6 +1098,10 @@ private void generateSupportingFiles(List files, Map bundl } } + if(new File(outputFilename).exists() && !support.isCanOverwrite()) { + this.templateProcessor.skip(outputFilename, String.format(Locale.ROOT, "Skipped existing overwiting file %s as overwriting is disabled by the template.", support.getDestinationFilename())); + continue; + } boolean shouldGenerate = true; if (supportingFilesToGenerate != null && !supportingFilesToGenerate.isEmpty()) { From 28ccdf42cba870805f4d1263a6efb8131bd7a4db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Gr=C3=B6ber?= Date: Thu, 23 Jan 2025 12:03:06 +0100 Subject: [PATCH 2/2] Fix log message --- .../main/java/org/openapitools/codegen/DefaultGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java index 64e5263ef4f3..32853b57bed0 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java @@ -1099,7 +1099,7 @@ private void generateSupportingFiles(List files, Map bundl } if(new File(outputFilename).exists() && !support.isCanOverwrite()) { - this.templateProcessor.skip(outputFilename, String.format(Locale.ROOT, "Skipped existing overwiting file %s as overwriting is disabled by the template.", support.getDestinationFilename())); + this.templateProcessor.skip(outputFilename, String.format(Locale.ROOT, "Skipped overwiting existing file %s as overwriting is disabled by used generator.", support.getDestinationFilename())); continue; }