Repository navigation
feat: Improve Jackson 2 compatibility for Swagger mappers - #5334
Conversation
5289bfc to
eeb724f
Compare
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The configuration ordering matches the stated compatibility goals and is comprehensively covered by focused tests.
Review effort: Balanced
Findings: None
What changed in this PR
Restores Jackson 2 compatibility defaults across Swagger Core mappers while retaining Swagger-specific overrides.
Changes:
- Applies shared Jackson 2 compatibility and accessor behavior.
- Preserves enum, date/time, decimal, ordering, and strict parsing policies.
- Expands compatibility tests across public and strict mappers.
| File | Description |
|---|---|
ObjectMapperFactory.java |
Centralizes compatibility configuration and mapper-specific overrides. |
ObjectMapperFactoryTest.java |
Adds broad compatibility and strict-mapper coverage. |
OrderedMapKeyCompatibilityTest.java |
Extends ordered-map validation to the strict mapper. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
3bdeb6b to
0c8a90c
Compare
Code reviewFound 2 issues:
Previously this method did not call any compatibility setup, so
|
70e62f7 to
08796a8
Compare
|
Pull Request
Restores selected Jackson 2 behavior after the Jackson 3 migration.
Each
MapperBuildernow callsconfigureForJackson2()before Swagger Core applies its own configuration.The compatibility configuration also restores behavior that
configureForJackson2()does not cover:Changes
Enum.toString().Enum.name().BigDecimaloutput limited to public output mappers.Known differences from Jackson 2
This PR does not restore all Jackson 2 behavior.
java.time.MonthJackson 3 handles
Monthas a date and time type. Jackson 2 handledMonthas a general enum.This PR disables
ONE_BASED_MONTHS. Therefore, numeric month values keep the Jackson 2 meaning:0is January.11is December.The serialized type still changes:
Month.JANUARYas"JANUARY".Month.JANUARYas0.Text input such as
"JANUARY"remains valid. The generated schema currently describesMonthas a string.Therefore, the serialized value and the generated schema use different types. A separate change is necessary to restore Jackson 2 string output.
Accessor acronyms
Jackson 3 removed the Jackson 2 legacy acronym rule.
configureForJackson2()does not restore this rule.The explicit accessor configuration accepts names such as
getvalue()andget_value(). It does not restore legacy acronym conversion.Examples:
getURL()urlURLgetIPhone()iphoneIPhoneisURL()urlURLThis difference affects JSON, YAML, input names, and generated schema properties. A custom accessor strategy is necessary for full acronym compatibility.
Type of Change
Checklist
Screenshots / Additional Context