Skip to content

Commit

Permalink
Determine REST_CLIENT_REACTIVE_JACKSON capability properly (#500)
Browse files Browse the repository at this point in the history
* fix: determine REST_CLIENT_REACTIVE_JACKSON capability properly

* Update deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java

Co-authored-by: Helber Belmiro <helber.belmiro@gmail.com>

* Update deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java

Co-authored-by: Helber Belmiro <helber.belmiro@gmail.com>

---------

Co-authored-by: Helber Belmiro <helber.belmiro@gmail.com>
  • Loading branch information
chberger and hbelmiro authored Sep 29, 2023
1 parent 06695ad commit ff9c374
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
<artifactId>swagger-parser</artifactId>
<version>${version.io.swagger.parser}</version>
</dependency>
<dependency>
<!-- Use Quarkus compatible version -->
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
</dependency>

<!-- OpenApi Generator -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.eclipse.microprofile.config.Config;
import org.openapitools.codegen.config.GlobalSettings;

Expand All @@ -33,6 +34,7 @@
import io.quarkiverse.openapi.generator.deployment.wrapper.OpenApiClientGeneratorWrapper;
import io.quarkiverse.openapi.generator.deployment.wrapper.OpenApiReactiveClientGeneratorWrapper;
import io.quarkus.bootstrap.prebuild.CodeGenException;
import io.quarkus.builder.Version;
import io.quarkus.deployment.Capability;
import io.quarkus.deployment.CodeGenContext;
import io.quarkus.deployment.CodeGenProvider;
Expand All @@ -53,6 +55,10 @@ public abstract class OpenApiGeneratorCodeGenBase implements CodeGenProvider {
private static final String DEFAULT_PACKAGE = "org.openapi.quarkus";
private static final String CONFIG_KEY_PROPERTY = "config-key";

private static final DefaultArtifactVersion BREAKING_QUARKUS_VERSION = new DefaultArtifactVersion("3.4.1");
private static final DefaultArtifactVersion TARGET_QUARKUS_VERSION = new DefaultArtifactVersion(Version.getVersion());
private static final String REST_CLIENT_REACTIVE_JACKSON_BEFORE_QUARKUS_3_4_1 = "io.quarkus.rest.client.reactive.jackson";

/**
* The input base directory from
*
Expand Down Expand Up @@ -132,7 +138,7 @@ public boolean trigger(CodeGenContext context) throws CodeGenException {
}

private static boolean isJacksonReactiveClientPresent(CodeGenContext context) {
return isExtensionCapabilityPresent(context, Capability.REST_CLIENT_REACTIVE_JACKSON);
return isExtensionCapabilityPresent(context, determineRestClientReactiveJacksonCapabilityId());
}

private static boolean isJacksonClassicClientPresent(CodeGenContext context) {
Expand All @@ -151,6 +157,14 @@ private static boolean isExtensionCapabilityPresent(CodeGenContext context, Stri
.anyMatch(capability::equals);
}

private static String determineRestClientReactiveJacksonCapabilityId() {
if (TARGET_QUARKUS_VERSION.compareTo(BREAKING_QUARKUS_VERSION) < 0) {
// in case the target Quarkus version is older than 3.4.1 we need to return the old Capability id for REST_CLIENT_REACTIVE_JACKSON
return REST_CLIENT_REACTIVE_JACKSON_BEFORE_QUARKUS_3_4_1;
}
return Capability.REST_CLIENT_REACTIVE_JACKSON;
}

// TODO: do not generate if the output dir has generated files and the openapi file has the same checksum of the previous run
protected void generate(final Config config, final Path openApiFilePath, final Path outDir,
Path templateDir, boolean isRestEasyReactive) {
Expand Down

0 comments on commit ff9c374

Please sign in to comment.