Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Determine REST_CLIENT_REACTIVE_JACKSON capability properly #500

Merged
merged 3 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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