From 61690f3ea9099b8cd9bf4cacc7205e727c16055f Mon Sep 17 00:00:00 2001 From: vladprado Date: Mon, 17 Mar 2025 23:31:36 -0300 Subject: [PATCH] #1045 - Refactor inputExtension method to inputExtensions #1045 - Refactor inputExtension method to inputExtensions# This is a combination of 2 commits. #1045 - Refactor inputExtension method to inputExtensions --- .../codegen/OpenApiGeneratorCodeGen.java | 13 +++++++++++++ .../codegen/OpenApiGeneratorCodeGenBase.java | 3 ++- .../codegen/OpenApiGeneratorJsonCodeGen.java | 14 -------------- .../codegen/OpenApiGeneratorOutputPaths.java | 4 +--- .../codegen/OpenApiGeneratorYamlCodeGen.java | 14 -------------- .../codegen/OpenApiGeneratorYmlCodeGen.java | 14 -------------- .../services/io.quarkus.deployment.CodeGenProvider | 4 +--- .../it/circuit/breaker/SimpleOpenApiTest.java | 2 +- 8 files changed, 18 insertions(+), 50 deletions(-) create mode 100644 client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGen.java delete mode 100644 client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorJsonCodeGen.java delete mode 100644 client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorYamlCodeGen.java delete mode 100644 client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorYmlCodeGen.java diff --git a/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGen.java b/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGen.java new file mode 100644 index 000000000..499304bc9 --- /dev/null +++ b/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGen.java @@ -0,0 +1,13 @@ +package io.quarkiverse.openapi.generator.deployment.codegen; + +public class OpenApiGeneratorCodeGen extends OpenApiGeneratorCodeGenBase { + @Override + public String providerId() { + return OpenApiGeneratorOutputPaths.OPENAPI_PATH; + } + + @Override + public String[] inputExtensions() { + return new String[] { JSON, YAML, YML }; + } +} diff --git a/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java b/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java index 619611011..079189d8a 100644 --- a/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java +++ b/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Optional; @@ -132,7 +133,7 @@ public boolean trigger(CodeGenContext context) throws CodeGenException { .filter(Files::isRegularFile) .filter(path -> { String fileName = path.getFileName().toString(); - return fileName.endsWith(inputExtension()) + return Arrays.stream(this.inputExtensions()).anyMatch(fileName::endsWith) && !filesToExclude.contains(fileName) && (filesToInclude.isEmpty() || filesToInclude.contains(fileName)); }).toList(); diff --git a/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorJsonCodeGen.java b/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorJsonCodeGen.java deleted file mode 100644 index f20ac5123..000000000 --- a/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorJsonCodeGen.java +++ /dev/null @@ -1,14 +0,0 @@ -package io.quarkiverse.openapi.generator.deployment.codegen; - -public class OpenApiGeneratorJsonCodeGen extends OpenApiGeneratorCodeGenBase { - - @Override - public String providerId() { - return OpenApiGeneratorOutputPaths.JSON_PATH; - } - - @Override - public String inputExtension() { - return JSON; - } -} diff --git a/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorOutputPaths.java b/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorOutputPaths.java index 0a22d8bda..2bfc71f6a 100644 --- a/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorOutputPaths.java +++ b/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorOutputPaths.java @@ -9,9 +9,7 @@ public class OpenApiGeneratorOutputPaths { - public static final String YAML_PATH = "open-api-yaml"; - public static final String YML_PATH = "open-api-yml"; - public static final String JSON_PATH = "open-api-json"; + public static final String OPENAPI_PATH = "open-api"; public static final String STREAM_PATH = "open-api-stream"; private static final Collection rootPaths = Arrays.asList(STREAM_PATH); diff --git a/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorYamlCodeGen.java b/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorYamlCodeGen.java deleted file mode 100644 index e3be71761..000000000 --- a/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorYamlCodeGen.java +++ /dev/null @@ -1,14 +0,0 @@ -package io.quarkiverse.openapi.generator.deployment.codegen; - -public class OpenApiGeneratorYamlCodeGen extends OpenApiGeneratorCodeGenBase { - - @Override - public String providerId() { - return OpenApiGeneratorOutputPaths.YAML_PATH; - } - - @Override - public String inputExtension() { - return YAML; - } -} \ No newline at end of file diff --git a/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorYmlCodeGen.java b/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorYmlCodeGen.java deleted file mode 100644 index 5c14d8154..000000000 --- a/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorYmlCodeGen.java +++ /dev/null @@ -1,14 +0,0 @@ -package io.quarkiverse.openapi.generator.deployment.codegen; - -public class OpenApiGeneratorYmlCodeGen extends OpenApiGeneratorCodeGenBase { - - @Override - public String providerId() { - return OpenApiGeneratorOutputPaths.YML_PATH; - } - - @Override - public String inputExtension() { - return YML; - } -} \ No newline at end of file diff --git a/client/deployment/src/main/resources/META-INF/services/io.quarkus.deployment.CodeGenProvider b/client/deployment/src/main/resources/META-INF/services/io.quarkus.deployment.CodeGenProvider index 075e856f5..da12e914a 100644 --- a/client/deployment/src/main/resources/META-INF/services/io.quarkus.deployment.CodeGenProvider +++ b/client/deployment/src/main/resources/META-INF/services/io.quarkus.deployment.CodeGenProvider @@ -1,4 +1,2 @@ -io.quarkiverse.openapi.generator.deployment.codegen.OpenApiGeneratorJsonCodeGen -io.quarkiverse.openapi.generator.deployment.codegen.OpenApiGeneratorYamlCodeGen -io.quarkiverse.openapi.generator.deployment.codegen.OpenApiGeneratorYmlCodeGen +io.quarkiverse.openapi.generator.deployment.codegen.OpenApiGeneratorCodeGen io.quarkiverse.openapi.generator.deployment.codegen.OpenApiGeneratorStreamCodeGen \ No newline at end of file diff --git a/client/integration-tests/circuit-breaker/src/test/java/io/quarkiverse/openapi/generator/it/circuit/breaker/SimpleOpenApiTest.java b/client/integration-tests/circuit-breaker/src/test/java/io/quarkiverse/openapi/generator/it/circuit/breaker/SimpleOpenApiTest.java index 73221966b..a0a5cd9ff 100644 --- a/client/integration-tests/circuit-breaker/src/test/java/io/quarkiverse/openapi/generator/it/circuit/breaker/SimpleOpenApiTest.java +++ b/client/integration-tests/circuit-breaker/src/test/java/io/quarkiverse/openapi/generator/it/circuit/breaker/SimpleOpenApiTest.java @@ -24,7 +24,7 @@ class SimpleOpenApiTest { @Test void circuitBreaker() throws IOException { - Path generatedRestClient = Paths.get("target", "generated-sources", "open-api-json", "org", "acme", + Path generatedRestClient = Paths.get("target", "generated-sources", "open-api", "org", "acme", "openapi", "simple", "api", "DefaultApi.java"); assertThat(generatedRestClient)