Skip to content
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 @@ -277,9 +277,9 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {

{{#useJackson3}}
Consumer<HttpMessageConverters.ClientBuilder> messageConverters = builder -> {
builder.addCustomConverter(new JacksonJsonHttpMessageConverter(mapper));
builder.registerDefaults().withJsonConverter(new JacksonJsonHttpMessageConverter(mapper));
{{#withXml}}
builder.addCustomConverter(new JacksonXmlHttpMessageConverter(xmlMapper));
builder.withXmlConverter(new JacksonXmlHttpMessageConverter(xmlMapper));
{{/withXml}}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ ext {
jakarta_annotation_version = "2.1.1"
{{/useSpringBoot4}}
{{#useSpringBoot4}}
spring_web_version = "7.0.5"
spring_web_version = "7.0.8"
jakarta_annotation_version = "3.0.0"
{{/useSpringBoot4}}
bean_validation_version = "3.1.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@
{{/performBeanValidation}}
{{/useSpringBoot4}}
{{#useSpringBoot4}}
<spring-web-version>7.0.5</spring-web-version>
<spring-web-version>7.0.8</spring-web-version>
{{#useJackson3}}
<jackson-version>3.1.5</jackson-version>
{{/useJackson3}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ ext {
jackson_databind_nullable_version = "0.2.11"
{{/openApiNullable}}
{{#useSpringBoot4}}
spring_web_version = "7.0.5"
spring_web_version = "7.0.8"
jakarta_annotation_version = "3.0.0"
bean_validation_version = "3.1.1"
{{/useSpringBoot4}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@
{{/swagger2AnnotationLibrary}}

{{#useSpringBoot4}}
<spring-web-version>7.0.5</spring-web-version>
<spring-web-version>7.0.8</spring-web-version>
{{#useJackson3}}
<jackson-version>3.1.5</jackson-version>
{{/useJackson3}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3702,6 +3702,33 @@ public void testJackson3DefaultMapperFallsBackToDefaultDateFormat_issue_24588()
}
}

@Test(description = "Regression test for issue #24587: restclient with useJackson3=true must call"
+ " builder.registerDefaults().withJsonConverter(...) inside configureMessageConverters so default Spring converters"
+ " (ByteArray, String, Resource) are registered with Jackson as the JSON converter.")
public void testRestClientJackson3RegistersDefaults_issue_24587() {
final Path output = newTempFolder();
final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName(JAVA_GENERATOR)
.setLibrary(JavaClientCodegen.RESTCLIENT)
.setAdditionalProperties(Map.of(
CodegenConstants.API_PACKAGE, "xyz.abcdef.api",
JavaClientCodegen.USE_JACKSON_3, true,
JavaClientCodegen.USE_SPRING_BOOT4, true,
JavaClientCodegen.OPENAPI_NULLABLE, false
))
.setInputSpec("src/test/resources/3_1/java/petstore.yaml")
.setOutputDir(output.toString().replace("\\", "/"));

List<File> files = new DefaultGenerator().opts(configurator.toClientOptInput()).generate();

validateJavaSourceFiles(files);
assertFileContains(
output.resolve("src/main/java/xyz/abcdef/ApiClient.java"),
"Consumer<HttpMessageConverters.ClientBuilder> messageConverters = builder -> {",
"builder.registerDefaults().withJsonConverter(new JacksonJsonHttpMessageConverter(mapper));"
);
}


@Test
public void testRestClientWithUseSingleRequestParameter_issue_19406() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ ext {
jackson_version = "2.21.5"
jackson_annotations_version = "2.21"
jackson_databind_nullable_version = "0.2.11"
spring_web_version = "7.0.5"
spring_web_version = "7.0.8"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The sample regeneration for the Spring Boot 4 templates is incomplete, leaving three samples internally inconsistent: build.gradle now declares spring_web_version = "7.0.8" while the matching pom.xml in the same directory still pins <spring-web-version>7.0.5. This affects restclient-springBoot4-jackson2, resttemplate-springBoot4-jackson2, and resttemplate-springBoot4-jackson3-jspecify (the other three Spring Boot 4 samples bumped both files consistently). As generated artifacts, these samples should be reproducible from the templates (whose pom.mustache is already 7.0.8), so a Maven-based user of these samples would resolve Spring 7.0.5 while a Gradle user gets 7.0.8 — exactly the kind of sample drift this PR's commit intends to fix. Please regenerate these samples (or update the pom.xml to 7.0.8) so the Maven and Gradle artifacts match.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/java/restclient-springBoot4-jackson2/build.gradle, line 103:

<comment>The sample regeneration for the Spring Boot 4 templates is incomplete, leaving three samples internally inconsistent: `build.gradle` now declares `spring_web_version = "7.0.8"` while the matching `pom.xml` in the same directory still pins `<spring-web-version>7.0.5`. This affects restclient-springBoot4-jackson2, resttemplate-springBoot4-jackson2, and resttemplate-springBoot4-jackson3-jspecify (the other three Spring Boot 4 samples bumped both files consistently). As generated artifacts, these samples should be reproducible from the templates (whose pom.mustache is already 7.0.8), so a Maven-based user of these samples would resolve Spring 7.0.5 while a Gradle user gets 7.0.8 — exactly the kind of sample drift this PR's commit intends to fix. Please regenerate these samples (or update the pom.xml to 7.0.8) so the Maven and Gradle artifacts match.</comment>

<file context>
@@ -100,7 +100,7 @@ ext {
     jackson_annotations_version = "2.21"
     jackson_databind_nullable_version = "0.2.11"
-    spring_web_version = "7.0.5"
+    spring_web_version = "7.0.8"
     jakarta_annotation_version = "3.0.0"
     bean_validation_version = "3.1.1"
</file context>

jakarta_annotation_version = "3.0.0"
bean_validation_version = "3.1.1"
jodatime_version = "2.14.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<spring-web-version>7.0.5</spring-web-version>
<spring-web-version>7.0.8</spring-web-version>
<jackson-version>2.21.5</jackson-version>
<jakarta-annotation-version>3.0.0</jakarta-annotation-version>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ if(hasProperty('target') && target == 'android') {
ext {
jackson_version = "3.1.5"
jackson_annotations_version = "2.21"
spring_web_version = "7.0.5"
spring_web_version = "7.0.8"
jakarta_annotation_version = "3.0.0"
bean_validation_version = "3.1.1"
jodatime_version = "2.14.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<spring-web-version>7.0.5</spring-web-version>
<spring-web-version>7.0.8</spring-web-version>
<jackson-version>3.1.5</jackson-version>
<jakarta-annotation-version>3.0.0</jakarta-annotation-version>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ protected void init() {
public static RestClient.Builder buildRestClientBuilder(JsonMapper mapper) {

Consumer<HttpMessageConverters.ClientBuilder> messageConverters = builder -> {
builder.addCustomConverter(new JacksonJsonHttpMessageConverter(mapper));
builder.registerDefaults().withJsonConverter(new JacksonJsonHttpMessageConverter(mapper));
};

return RestClient.builder().configureMessageConverters(messageConverters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ if(hasProperty('target') && target == 'android') {
ext {
jackson_version = "3.1.5"
jackson_annotations_version = "2.21"
spring_web_version = "7.0.5"
spring_web_version = "7.0.8"
jakarta_annotation_version = "3.0.0"
bean_validation_version = "3.1.1"
jodatime_version = "2.14.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<spring-web-version>7.0.5</spring-web-version>
<spring-web-version>7.0.8</spring-web-version>
<jackson-version>3.1.5</jackson-version>
<jakarta-annotation-version>3.0.0</jakarta-annotation-version>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ protected void init() {
public static RestClient.Builder buildRestClientBuilder(JsonMapper mapper) {

Consumer<HttpMessageConverters.ClientBuilder> messageConverters = builder -> {
builder.addCustomConverter(new JacksonJsonHttpMessageConverter(mapper));
builder.registerDefaults().withJsonConverter(new JacksonJsonHttpMessageConverter(mapper));
};

return RestClient.builder().configureMessageConverters(messageConverters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ ext {
jackson_version = "2.21.5"
jackson_annotations_version = "2.21"
jackson_databind_nullable_version = "0.2.11"
spring_web_version = "7.0.5"
spring_web_version = "7.0.8"
jakarta_annotation_version = "3.0.0"
bean_validation_version = "3.1.1"
jodatime_version = "2.9.9"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<spring-web-version>7.0.5</spring-web-version>
<spring-web-version>7.0.8</spring-web-version>
<jackson-version>2.21.5</jackson-version>
<jakarta-annotation-version>3.0.0</jakarta-annotation-version>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ if(hasProperty('target') && target == 'android') {
ext {
jackson_version = "3.1.5"
jackson_annotations_version = "2.21"
spring_web_version = "7.0.5"
spring_web_version = "7.0.8"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Spring version now diverges within this regenerated sample: build.gradle was bumped to 7.0.8 but the sibling pom.xml still declares 7.0.5, so Maven and Gradle builds of the same sample use different Spring versions. Regenerate both build files from the template (which emits 7.0.8 for useSpringBoot4) to keep the sample in sync.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/build.gradle, line 102:

<comment>Spring version now diverges within this regenerated sample: build.gradle was bumped to 7.0.8 but the sibling pom.xml still declares 7.0.5, so Maven and Gradle builds of the same sample use different Spring versions. Regenerate both build files from the template (which emits 7.0.8 for useSpringBoot4) to keep the sample in sync.</comment>

<file context>
@@ -99,7 +99,7 @@ if(hasProperty('target') && target == 'android') {
     jackson_version = "3.1.5"
     jackson_annotations_version = "2.21"
-    spring_web_version = "7.0.5"
+    spring_web_version = "7.0.8"
     jakarta_annotation_version = "3.0.0"
     bean_validation_version = "3.1.1"
</file context>

jakarta_annotation_version = "3.0.0"
bean_validation_version = "3.1.1"
jodatime_version = "2.9.9"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<spring-web-version>7.0.5</spring-web-version>
<spring-web-version>7.0.8</spring-web-version>
<jackson-version>3.1.5</jackson-version>
<jakarta-annotation-version>3.0.0</jakarta-annotation-version>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ if(hasProperty('target') && target == 'android') {
ext {
jackson_version = "3.1.5"
jackson_annotations_version = "2.21"
spring_web_version = "7.0.5"
spring_web_version = "7.0.8"
jakarta_annotation_version = "3.0.0"
bean_validation_version = "3.1.1"
jodatime_version = "2.9.9"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<spring-web-version>7.0.5</spring-web-version>
<spring-web-version>7.0.8</spring-web-version>
<jackson-version>3.1.5</jackson-version>
<jakarta-annotation-version>3.0.0</jakarta-annotation-version>

Expand Down
Loading