forked from loafle/openapi-generator-original
adjust jersey2/jersey3 templates (#21171)
* respect useJakartaEE in jersey3 * useJakarteEE=true in jersey3 samples * don't force jakarta package for jersey3 * adjust whitespace between jersey2 and jersey3 * enforce useJakartaEe for jersey3, warn on misuse for jersey 2 * set useJakartaEe for jersey3, generate samples
This commit is contained in:
parent
3fadfe3889
commit
9a289e9713
@ -587,6 +587,9 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
|||||||
// The flag below should be set for all Java libraries, but the templates need to be ported
|
// The flag below should be set for all Java libraries, but the templates need to be ported
|
||||||
// one by one for each library.
|
// one by one for each library.
|
||||||
supportsAdditionalPropertiesWithComposedSchema = true;
|
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) {
|
} else if (libJersey3) {
|
||||||
additionalProperties.put("jersey3", true);
|
additionalProperties.put("jersey3", true);
|
||||||
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
|
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
|
||||||
@ -603,6 +606,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
|||||||
// The flag below should be set for all Java libraries, but the templates need to be ported
|
// The flag below should be set for all Java libraries, but the templates need to be ported
|
||||||
// one by one for each library.
|
// one by one for each library.
|
||||||
supportsAdditionalPropertiesWithComposedSchema = true;
|
supportsAdditionalPropertiesWithComposedSchema = true;
|
||||||
|
setUseJakartaEe(true);
|
||||||
applyJakartaPackage();
|
applyJakartaPackage();
|
||||||
} else if (libNative) {
|
} else if (libNative) {
|
||||||
supportingFiles.add(new SupportingFile("ApiResponse.mustache", invokerFolder, "ApiResponse.java"));
|
supportingFiles.add(new SupportingFile("ApiResponse.mustache", invokerFolder, "ApiResponse.java"));
|
||||||
|
@ -1021,7 +1021,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
|||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the object with the provided key to the MultiPart.
|
* Adds the object with the provided key to the MultiPart.
|
||||||
* Based on the object type sets Content-Disposition and Content-Type.
|
* Based on the object type sets Content-Disposition and Content-Type.
|
||||||
*
|
*
|
||||||
|
@ -1386,7 +1386,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
|||||||
protected Client buildHttpClient() {
|
protected Client buildHttpClient() {
|
||||||
// Create ClientConfig if it has not been initialized yet
|
// Create ClientConfig if it has not been initialized yet
|
||||||
if (clientConfig == null) {
|
if (clientConfig == null) {
|
||||||
clientConfig = getDefaultClientConfig();
|
clientConfig = getDefaultClientConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
|
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
|
||||||
|
@ -12,8 +12,8 @@ import {{javaxPackage}}.ws.rs.core.GenericType;
|
|||||||
{{/imports}}
|
{{/imports}}
|
||||||
|
|
||||||
{{#useBeanValidation}}
|
{{#useBeanValidation}}
|
||||||
import jakarta.validation.constraints.*;
|
import {{javaxPackage}}.validation.constraints.*;
|
||||||
import jakarta.validation.Valid;
|
import {{javaxPackage}}.validation.Valid;
|
||||||
|
|
||||||
{{/useBeanValidation}}
|
{{/useBeanValidation}}
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -17,8 +17,8 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
{{#useBeanValidation}}
|
{{#useBeanValidation}}
|
||||||
import jakarta.validation.constraints.*;
|
import {{javaxPackage}}.validation.constraints.*;
|
||||||
import jakarta.validation.Valid;
|
import {{javaxPackage}}.validation.Valid;
|
||||||
|
|
||||||
{{/useBeanValidation}}
|
{{/useBeanValidation}}
|
||||||
/**
|
/**
|
||||||
|
@ -152,7 +152,6 @@ dependencies {
|
|||||||
{{#useReflectionEqualsHashCode}}
|
{{#useReflectionEqualsHashCode}}
|
||||||
implementation "org.apache.commons:commons-lang3:$commons_lang3_version"
|
implementation "org.apache.commons:commons-lang3:$commons_lang3_version"
|
||||||
{{/useReflectionEqualsHashCode}}
|
{{/useReflectionEqualsHashCode}}
|
||||||
|
|
||||||
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
|
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
|
||||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
|
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,8 @@ import android.os.Parcelable;
|
|||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
{{/parcelableModel}}
|
{{/parcelableModel}}
|
||||||
{{#useBeanValidation}}
|
{{#useBeanValidation}}
|
||||||
import jakarta.validation.constraints.*;
|
import {{javaxPackage}}.validation.constraints.*;
|
||||||
import jakarta.validation.Valid;
|
import {{javaxPackage}}.validation.Valid;
|
||||||
{{/useBeanValidation}}
|
{{/useBeanValidation}}
|
||||||
{{#performBeanValidation}}
|
{{#performBeanValidation}}
|
||||||
import org.hibernate.validator.constraints.*;
|
import org.hibernate.validator.constraints.*;
|
||||||
|
@ -408,8 +408,14 @@
|
|||||||
<jackson-version>2.17.1</jackson-version>
|
<jackson-version>2.17.1</jackson-version>
|
||||||
<jackson-databind-version>2.17.1</jackson-databind-version>
|
<jackson-databind-version>2.17.1</jackson-databind-version>
|
||||||
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
|
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
|
||||||
|
{{#useJakartaEe}}
|
||||||
<jakarta-annotation-version>2.1.1</jakarta-annotation-version>
|
<jakarta-annotation-version>2.1.1</jakarta-annotation-version>
|
||||||
<beanvalidation-version>3.0.2</beanvalidation-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>
|
<junit-version>5.10.0</junit-version>
|
||||||
{{#hasHttpSignatureMethods}}
|
{{#hasHttpSignatureMethods}}
|
||||||
<http-signature-version>1.8</http-signature-version>
|
<http-signature-version>1.8</http-signature-version>
|
||||||
|
@ -800,7 +800,7 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the object with the provided key to the MultiPart.
|
* Adds the object with the provided key to the MultiPart.
|
||||||
* Based on the object type sets Content-Disposition and Content-Type.
|
* Based on the object type sets Content-Disposition and Content-Type.
|
||||||
*
|
*
|
||||||
|
@ -800,7 +800,7 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the object with the provided key to the MultiPart.
|
* Adds the object with the provided key to the MultiPart.
|
||||||
* Based on the object type sets Content-Disposition and Content-Type.
|
* Based on the object type sets Content-Disposition and Content-Type.
|
||||||
*
|
*
|
||||||
|
@ -941,7 +941,7 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the object with the provided key to the MultiPart.
|
* Adds the object with the provided key to the MultiPart.
|
||||||
* Based on the object type sets Content-Disposition and Content-Type.
|
* Based on the object type sets Content-Disposition and Content-Type.
|
||||||
*
|
*
|
||||||
|
@ -941,7 +941,7 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the object with the provided key to the MultiPart.
|
* Adds the object with the provided key to the MultiPart.
|
||||||
* Based on the object type sets Content-Disposition and Content-Type.
|
* Based on the object type sets Content-Disposition and Content-Type.
|
||||||
*
|
*
|
||||||
|
@ -121,7 +121,6 @@ dependencies {
|
|||||||
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
|
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
|
||||||
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
||||||
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
|
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
|
||||||
|
|
||||||
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
|
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
|
||||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
|
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
|
||||||
}
|
}
|
||||||
|
@ -1142,7 +1142,7 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
protected Client buildHttpClient() {
|
protected Client buildHttpClient() {
|
||||||
// Create ClientConfig if it has not been initialized yet
|
// Create ClientConfig if it has not been initialized yet
|
||||||
if (clientConfig == null) {
|
if (clientConfig == null) {
|
||||||
clientConfig = getDefaultClientConfig();
|
clientConfig = getDefaultClientConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
|
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
|
||||||
|
@ -129,7 +129,6 @@ dependencies {
|
|||||||
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
|
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
|
||||||
implementation "jakarta.validation:jakarta.validation-api:$bean_validation_version"
|
implementation "jakarta.validation:jakarta.validation-api:$bean_validation_version"
|
||||||
implementation "org.apache.commons:commons-lang3:$commons_lang3_version"
|
implementation "org.apache.commons:commons-lang3:$commons_lang3_version"
|
||||||
|
|
||||||
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
|
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
|
||||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
|
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
|
||||||
}
|
}
|
||||||
|
@ -1381,7 +1381,7 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
protected Client buildHttpClient() {
|
protected Client buildHttpClient() {
|
||||||
// Create ClientConfig if it has not been initialized yet
|
// Create ClientConfig if it has not been initialized yet
|
||||||
if (clientConfig == null) {
|
if (clientConfig == null) {
|
||||||
clientConfig = getDefaultClientConfig();
|
clientConfig = getDefaultClientConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
|
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
|
||||||
|
@ -849,7 +849,7 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the object with the provided key to the MultiPart.
|
* Adds the object with the provided key to the MultiPart.
|
||||||
* Based on the object type sets Content-Disposition and Content-Type.
|
* Based on the object type sets Content-Disposition and Content-Type.
|
||||||
*
|
*
|
||||||
|
@ -800,7 +800,7 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the object with the provided key to the MultiPart.
|
* Adds the object with the provided key to the MultiPart.
|
||||||
* Based on the object type sets Content-Disposition and Content-Type.
|
* Based on the object type sets Content-Disposition and Content-Type.
|
||||||
*
|
*
|
||||||
|
@ -925,7 +925,7 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the object with the provided key to the MultiPart.
|
* Adds the object with the provided key to the MultiPart.
|
||||||
* Based on the object type sets Content-Disposition and Content-Type.
|
* Based on the object type sets Content-Disposition and Content-Type.
|
||||||
*
|
*
|
||||||
|
@ -925,7 +925,7 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the object with the provided key to the MultiPart.
|
* Adds the object with the provided key to the MultiPart.
|
||||||
* Based on the object type sets Content-Disposition and Content-Type.
|
* Based on the object type sets Content-Disposition and Content-Type.
|
||||||
*
|
*
|
||||||
|
@ -1023,7 +1023,7 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the object with the provided key to the MultiPart.
|
* Adds the object with the provided key to the MultiPart.
|
||||||
* Based on the object type sets Content-Disposition and Content-Type.
|
* Based on the object type sets Content-Disposition and Content-Type.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user