Skip to content

Commit a25372e

Browse files
committed
Merge branch '2.20' into 2.x
2 parents 44de37f + e663b4f commit a25372e

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed

release-notes/VERSION-2.x

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ Project: jackson-databind
2020
(contributed by @wrongwrong)
2121
#5361: Fix Maven SBOM publishing
2222

23+
2.20.2 (not yet released)
24+
25+
#5393: `@JsonAnyGetter property gets included in generated schema since 2.19.0`
26+
(reported by @victor-noel-pfx)
27+
(fix by Joo-Hyuk K)
28+
2329
2.20.1 (30-Oct-2025)
2430

2531
#5292: `MapperFeature.FIX_FIELD_NAME_UPPER_CASE_PREFIX` does not work with

src/main/java/com/fasterxml/jackson/databind/ser/AnyGetterWriter.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.fasterxml.jackson.core.*;
66
import com.fasterxml.jackson.databind.*;
77
import com.fasterxml.jackson.databind.introspect.AnnotatedMember;
8+
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonObjectFormatVisitor;
89
import com.fasterxml.jackson.databind.ser.std.MapSerializer;
910

1011
/**
@@ -89,6 +90,13 @@ public void serializeAsField(Object bean, JsonGenerator gen, SerializerProvider
8990
getAndSerialize(bean, gen, prov);
9091
}
9192

93+
@Override // @since 2.20
94+
public void depositSchemaProperty(JsonObjectFormatVisitor v, SerializerProvider provider) throws JsonMappingException {
95+
// 18-Nov-2025: [databind#5393] @JsonAnyGetter was getting included in generated schema
96+
97+
// no-op
98+
}
99+
92100
/**
93101
* @since 2.3
94102
*/
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package com.fasterxml.jackson.databind.jsonschema;
2+
3+
import java.util.*;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
import com.fasterxml.jackson.annotation.*;
8+
import com.fasterxml.jackson.databind.*;
9+
import com.fasterxml.jackson.databind.jsonFormatVisitors.*;
10+
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;
11+
12+
import static org.junit.jupiter.api.Assertions.*;
13+
14+
// [databind#5393] @JsonAnyGetter property gets included in generated schema since 2.19.0
15+
public class FormatVisitor5393Test
16+
extends DatabindTestUtil
17+
{
18+
static class TestJsonIgnoredProperties
19+
{
20+
@JsonIgnore
21+
public String ignoredProp;
22+
23+
public String normalProperty;
24+
25+
@JsonProperty("renamedProperty")
26+
public String someProperty;
27+
28+
// [databind#5393]
29+
@JsonAnyGetter
30+
public Map<String, Object> anyProperties() {
31+
return new TreeMap<>();
32+
}
33+
}
34+
35+
private final ObjectMapper MAPPER = newJsonMapper();
36+
37+
// [databind#5393]: regression wrt `@JsonAnyGetter`
38+
@Test
39+
public void ignoreExplicitlyIgnoredAndAnyGetter() throws Exception {
40+
final TreeSet<String> expected = new TreeSet<>();
41+
expected.add("normalProperty");
42+
expected.add("renamedProperty");
43+
44+
final Set<String> actual = new TreeSet<>();
45+
MAPPER.acceptJsonFormatVisitor(TestJsonIgnoredProperties.class,
46+
new JsonFormatVisitorWrapper.Base() {
47+
@Override
48+
public JsonObjectFormatVisitor expectObjectFormat(JavaType type) {
49+
return new JsonObjectFormatVisitor.Base() {
50+
@Override
51+
public void property(BeanProperty prop) {
52+
actual.add(prop.getName());
53+
}
54+
55+
@Override
56+
public void property(String name, JsonFormatVisitable handler, JavaType propertyTypeHint) {
57+
actual.add(name);
58+
}
59+
60+
@Override
61+
public void optionalProperty(BeanProperty prop) {
62+
actual.add(prop.getName());
63+
}
64+
65+
@Override
66+
public void optionalProperty(String name, JsonFormatVisitable handler, JavaType propertyTypeHint) {
67+
actual.add(name);
68+
}
69+
};
70+
}
71+
});
72+
73+
assertEquals(expected, actual);
74+
}
75+
}

0 commit comments

Comments
 (0)