Skip to content

adjust jersey2/jersey3 templates #21171

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

Merged
merged 6 commits into from
Apr 29, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,9 @@ public void processOpts() {
// The flag below should be set for all Java libraries, but the templates need to be ported
// one by one for each library.
supportsAdditionalPropertiesWithComposedSchema = true;
if (useJakartaEe) {
LOGGER.warn("Jersey 2 is not compatible with Jakarta EE. Please use Jersey 3 or set {} to false.", USE_JAKARTA_EE);
}
} else if (libJersey3) {
additionalProperties.put("jersey3", true);
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
Expand All @@ -603,6 +606,7 @@ public void processOpts() {
// The flag below should be set for all Java libraries, but the templates need to be ported
// one by one for each library.
supportsAdditionalPropertiesWithComposedSchema = true;
setUseJakartaEe(true);
applyJakartaPackage();
} else if (libNative) {
supportingFiles.add(new SupportingFile("ApiResponse.mustache", invokerFolder, "ApiResponse.java"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
return entity;
}

/**
/**
* Adds the object with the provided key to the MultiPart.
* Based on the object type sets Content-Disposition and Content-Type.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
protected Client buildHttpClient() {
// Create ClientConfig if it has not been initialized yet
if (clientConfig == null) {
clientConfig = getDefaultClientConfig();
clientConfig = getDefaultClientConfig();
}

ClientBuilder clientBuilder = ClientBuilder.newBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {{javaxPackage}}.ws.rs.core.GenericType;
{{/imports}}

{{#useBeanValidation}}
import jakarta.validation.constraints.*;
import jakarta.validation.Valid;
import {{javaxPackage}}.validation.constraints.*;
import {{javaxPackage}}.validation.Valid;

{{/useBeanValidation}}
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import java.util.List;
import java.util.Map;

{{#useBeanValidation}}
import jakarta.validation.constraints.*;
import jakarta.validation.Valid;
import {{javaxPackage}}.validation.constraints.*;
import {{javaxPackage}}.validation.Valid;

{{/useBeanValidation}}
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ dependencies {
{{#useReflectionEqualsHashCode}}
implementation "org.apache.commons:commons-lang3:$commons_lang3_version"
{{/useReflectionEqualsHashCode}}

testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ import android.os.Parcelable;
import android.os.Parcel;
{{/parcelableModel}}
{{#useBeanValidation}}
import jakarta.validation.constraints.*;
import jakarta.validation.Valid;
import {{javaxPackage}}.validation.constraints.*;
import {{javaxPackage}}.validation.Valid;
{{/useBeanValidation}}
{{#performBeanValidation}}
import org.hibernate.validator.constraints.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,14 @@
<jackson-version>2.17.1</jackson-version>
<jackson-databind-version>2.17.1</jackson-databind-version>
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
{{#useJakartaEe}}
<jakarta-annotation-version>2.1.1</jakarta-annotation-version>
<beanvalidation-version>3.0.2</beanvalidation-version>
{{/useJakartaEe}}
{{^useJakartaEe}}
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
<beanvalidation-version>2.0.2</beanvalidation-version>
{{/useJakartaEe}}
<junit-version>5.10.0</junit-version>
{{#hasHttpSignatureMethods}}
<http-signature-version>1.8</http-signature-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ public Entity<?> serialize(Object obj, Map<String, Object> formParams, String co
return entity;
}

/**
/**
* Adds the object with the provided key to the MultiPart.
* Based on the object type sets Content-Disposition and Content-Type.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ public Entity<?> serialize(Object obj, Map<String, Object> formParams, String co
return entity;
}

/**
/**
* Adds the object with the provided key to the MultiPart.
* Based on the object type sets Content-Disposition and Content-Type.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ public Entity<?> serialize(Object obj, Map<String, Object> formParams, String co
return entity;
}

/**
/**
* Adds the object with the provided key to the MultiPart.
* Based on the object type sets Content-Disposition and Content-Type.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ public Entity<?> serialize(Object obj, Map<String, Object> formParams, String co
return entity;
}

/**
/**
* Adds the object with the provided key to the MultiPart.
* Based on the object type sets Content-Disposition and Content-Type.
*
Expand Down
1 change: 0 additions & 1 deletion samples/client/petstore/java/jersey3-oneOf/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ dependencies {
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"

testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ public <T> ApiResponse<T> invokeAPI(String path, String method, List<Pair> query
protected Client buildHttpClient() {
// Create ClientConfig if it has not been initialized yet
if (clientConfig == null) {
clientConfig = getDefaultClientConfig();
clientConfig = getDefaultClientConfig();
}

ClientBuilder clientBuilder = ClientBuilder.newBuilder();
Expand Down
1 change: 0 additions & 1 deletion samples/client/petstore/java/jersey3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ dependencies {
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
implementation "jakarta.validation:jakarta.validation-api:$bean_validation_version"
implementation "org.apache.commons:commons-lang3:$commons_lang3_version"

testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,7 @@ public <T> ApiResponse<T> invokeAPI(String path, String method, List<Pair> query
protected Client buildHttpClient() {
// Create ClientConfig if it has not been initialized yet
if (clientConfig == null) {
clientConfig = getDefaultClientConfig();
clientConfig = getDefaultClientConfig();
}

ClientBuilder clientBuilder = ClientBuilder.newBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ public Entity<?> serialize(Object obj, Map<String, Object> formParams, String co
return entity;
}

/**
/**
* Adds the object with the provided key to the MultiPart.
* Based on the object type sets Content-Disposition and Content-Type.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ public Entity<?> serialize(Object obj, Map<String, Object> formParams, String co
return entity;
}

/**
/**
* Adds the object with the provided key to the MultiPart.
* Based on the object type sets Content-Disposition and Content-Type.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ public Entity<?> serialize(Object obj, Map<String, Object> formParams, String co
return entity;
}

/**
/**
* Adds the object with the provided key to the MultiPart.
* Based on the object type sets Content-Disposition and Content-Type.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ public Entity<?> serialize(Object obj, Map<String, Object> formParams, String co
return entity;
}

/**
/**
* Adds the object with the provided key to the MultiPart.
* Based on the object type sets Content-Disposition and Content-Type.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ public Entity<?> serialize(Object obj, Map<String, Object> formParams, String co
return entity;
}

/**
/**
* Adds the object with the provided key to the MultiPart.
* Based on the object type sets Content-Disposition and Content-Type.
*
Expand Down
Loading