GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat: API to add Jackson modules / customize immutable Jackson 3 mappers by pjfanning · Pull Request #5324 · swagger-api/swagger-core Conversation
Contributor
Targets the ProblemJackson 3 Json.mapper().registerModule(new KotlinModule.Builder().build()); and it worked for two reasons: On This is the Jackson 3 version of what I proposed in #4052 / draft PR #4053 (Jackson 2, builder-based Changes
|
| Jackson 2 | 3.0.0 |
|---|---|
Json.mapper().registerModule(m) + same on Yaml/Json31/Yaml31 |
ObjectMapperFactory.addModule(m) |
Json.mapper().registerModule(m) (JSON only, on purpose) |
Json.addModule(m) |
Json.mapper().setSerializationInclusion(...) / .configure(...) / .addMixIn(...) |
Json.configure(b -> ...) |
new ModelResolver(myMapper) |
unchanged |
Note for the migration guide: Jackson 3 databind bundles JSR-310, JDK8 Optional and parameter-names support, so JavaTimeModule — historically the #1 reason to call registerModule — is no longer needed.
MapperCustomizerTest (11): module reaches all five targets; customizer ordering (user overrides NON_NULL); registering after first use rebuilds and re-caches; remove/clear; strict generic mapper untouched; per-mapper addModule/configure keep swagger mixins; explicit mapper(ObjectMapper) survives factory changes until reset(); Json31.reset() also resets the converter mapper.ModelConvertersCustomizerTest (4): a SNAKE_CASE naming strategy registered after ModelConverters.getInstance() changes resolved property names (3.0 and 3.1 instances); user-added converter keeps its position across the refresh; removing the customizer restores defaults.All new public classes/methods carry @since 3.0.0. Everything added is new static/instance API — no signature changes on the 3.0.0 branch.
Not in this PR (possible follow-ups): ServiceLoader discovery of MapperCustomizer, and a jacksonModules option for the maven/gradle plugins.
🤖 Generated with Claude Code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Jackson 3 ObjectMappers are immutable, so the Jackson 2 idiom Json.mapper().registerModule(...) no longer works, and the default ModelResolver copies its mapper so a replaced Json.mapper() would not reach model introspection either. - ObjectMapperFactory: MapperCustomizer registry (addCustomizer, addModule(s), remove/clear, generation counter) applied as the last step of every mapper it builds, keyed by MapperTarget. - Json/Yaml/Json31/Yaml31: mapper() is now lazily built and rebuilt when customizers change; new mapper(ObjectMapper), configure(...), addModule(...) and reset() per class (shared MapperHolder). - ModelConverters: rebuilds only its default ModelResolver in place when the factory generation moves, keeping user-added converters. - Fix stale _intr() javadoc in AbstractModelConverter. - Tests: MapperCustomizerTest, ModelConvertersCustomizerTest. Jackson 3 follow-up to swagger-api#4052 / swagger-api#4053; related swagger-api#3837, swagger-api#4991, swagger-api#5314. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
One or more issues must be addressed before approval.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 3
Adds Jackson 3 mapper customization APIs, replaceable shared mappers, and automatic ModelConverters refresh behavior.
Changes:
| File | Description |
|---|---|
| modules/swagger-core/src/test/java/io/swagger/v3/core/util/MapperCustomizerTest.java | Updated as part of this pull request. |
| modules/swagger-core/src/test/java/io/swagger/v3/core/resolving/ModelConvertersCustomizerTest.java | Updated as part of this pull request. |
| modules/swagger-core/src/main/java/io/swagger/v3/core/util/Yaml31.java | Updated as part of this pull request. |
| modules/swagger-core/src/main/java/io/swagger/v3/core/util/Yaml.java | Updated as part of this pull request. |
| modules/swagger-core/src/main/java/io/swagger/v3/core/util/ObjectMapperFactory.java | Updated as part of this pull request. |
| modules/swagger-core/src/main/java/io/swagger/v3/core/util/MapperTarget.java | Updated as part of this pull request. |
| modules/swagger-core/src/main/java/io/swagger/v3/core/util/MapperHolder.java | Updated as part of this pull request. |
| modules/swagger-core/src/main/java/io/swagger/v3/core/util/MapperCustomizer.java | Updated as part of this pull request. |
| modules/swagger-core/src/main/java/io/swagger/v3/core/util/Json31.java | Updated as part of this pull request. |
| modules/swagger-core/src/main/java/io/swagger/v3/core/util/Json.java | Updated as part of this pull request. |
| modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/AbstractModelConverter.java | Updated as part of this pull request. |
| modules/swagger-core/src/main/java/io/swagger/v3/core/converter/ModelConverters.java | Updated as part of this pull request. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Add breaking change section to MIGRATION.md documenting that components caching mappers at startup won't see customizers registered later. Includes problem scenario, solution pattern, affected APIs, and affected swagger-rest components (DefaultParameterExtension, OpenAPI31SpecFilter). Also adds migration checklist item. Related to PR swagger-api#5324 mapper customization API.
There was an error while loading. Please reload this page.
|
@daniel-kmiecik thanks for merging this. I'm away for a few days so I am not in a position to act on the Copilot review items above. Without looking at them in detail, they do appear to raise some valid points. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@pjfanning no worries. I’ve already analyzed them. One comment has been fixed, while the other two have been documented since they concern consumer-side usage. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.