Skip to content

feat: migrate to jackson 3 - #5031

Closed
vpelikh wants to merge 2 commits into
swagger-api:masterfrom
vpelikh:update-to-java-17
Closed

vpelikh wants to merge 2 commits into
swagger-api:masterfrom
vpelikh:update-to-java-17

Conversation

@vpelikh

@vpelikh vpelikh commented Jan 1, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR consists of two commits:

  • update to java 17 (minimum version for jackson 3)
  • update to jackson 3

Fixes: #4991

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor (non-breaking change)
  • 🧪 Tests
  • 📝 Documentation
  • 🧹 Chore (build or tooling)

Checklist

  • I have added/updated tests as needed
  • I have added/updated documentation where applicable
  • The PR title is descriptive
  • The code builds and passes tests locally
  • I have linked related issues (if any)

Screenshots / Additional Context

@vpelikh
vpelikh force-pushed the update-to-java-17 branch from 7633f49 to 7b93974 Compare January 1, 2026 13:48
@vpelikh vpelikh changed the title feat: migrate to java 17 feat: migrate to jackson 3 Jan 3, 2026
@cbot59

cbot59 commented Jan 4, 2026

Copy link
Copy Markdown

I think we need to introduce constructor for ModelResolver(JsonMapper) and deprecate the old constructor so the newer release requires user to Jackson3 instead.

currently I have such usage on ModelResolver when using springdoc-openapi
Screenshot 2026-01-04 at 10 17 11

my first attempt to migrate to Jackson3 would be

public ModelResolver modelResolver(JsonMapper jsonMapper) {
        return new ModelResolver(jsonMapper);
    }

as it is more straightforward

@vpelikh
vpelikh force-pushed the update-to-java-17 branch from 0de7198 to f60ee1e Compare January 4, 2026 13:36
@vpelikh

vpelikh commented Jan 4, 2026

Copy link
Copy Markdown
Contributor Author

I have removed many of the changes associated with java 17, so the PR is now much smaller.

@cbot59, thanks for the comment! JsonMapper is a descendant of ObjectMapper, so return new ModelResolver(jsonMapper); should work without a new constructor.

@WilliamAGH

Copy link
Copy Markdown

Hey everyone -- thanks to @vpelikh, we now have Jackson 3 and Java 17 support.

But I didn't want to wait, so I have it available here! His branch is available as a dependency, just add this to your build.gradle file or pom.xml equivalent:

configurations.all {
    resolutionStrategy.dependencySubstitution {
        substitute(module("io.swagger.core.v3:swagger-core-jakarta"))
            .using(module("com.github.WilliamAGH.swagger-core:swagger-core-jakarta:jackson-3-SNAPSHOT"))
        substitute(module("io.swagger.core.v3:swagger-models-jakarta"))
            .using(module("com.github.WilliamAGH.swagger-core:swagger-models-jakarta:jackson-3-SNAPSHOT"))
        substitute(module("io.swagger.core.v3:swagger-annotations-jakarta"))
            .using(module("com.github.WilliamAGH.swagger-core:swagger-annotations-jakarta:jackson-3-SNAPSHOT"))
    }

@piotrooo

Copy link
Copy Markdown

@cbot59, thanks for the comment! JsonMapper is a descendant of ObjectMapper, so return new ModelResolver(jsonMapper); should work without a new constructor.

No, it doesn't, because the ObjectMapper used by Swagger comes from the com.fasterxml.jackson.databind package (Jackson v2), while in v3 the JsonMapper comes from tools.jackson.databind.

@KP-EV

KP-EV commented Jan 27, 2026

Copy link
Copy Markdown

Any update on this?

@larsf96

larsf96 commented Jan 29, 2026

Copy link
Copy Markdown

Any chance that a maintainer takes a look here?
Is there any workaround to use Spring Boot 4 with SpringDoc 3 without waiting for this?

@WilliamAGH

Copy link
Copy Markdown

Any chance that a maintainer takes a look here? Is there any workaround to use Spring Boot 4 with SpringDoc 3 without waiting for this?

Yes, I’ve had this workaround in use in production for the last 2 weeks:

#5031 (comment)

@larsf96

larsf96 commented Jan 30, 2026

Copy link
Copy Markdown

configurations.all {
resolutionStrategy.dependencySubstitution {
substitute(module("io.swagger.core.v3:swagger-core-jakarta"))
.using(module("com.github.WilliamAGH.swagger-core:swagger-core-jakarta:jackson-3-SNAPSHOT"))
substitute(module("io.swagger.core.v3:swagger-models-jakarta"))
.using(module("com.github.WilliamAGH.swagger-core:swagger-models-jakarta:jackson-3-SNAPSHOT"))
substitute(module("io.swagger.core.v3:swagger-annotations-jakarta"))
.using(module("com.github.WilliamAGH.swagger-core:swagger-annotations-jakarta:jackson-3-SNAPSHOT"))
}

This does not work for me:

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springdoc.core.providers.ObjectMapperProvider.<init>(ObjectMapperProvider.java:75)

The following method did not exist:

    'com.fasterxml.jackson.databind.ObjectMapper io.swagger.v3.core.util.Json31.mapper()'

The calling method's class, org.springdoc.core.providers.ObjectMapperProvider, was loaded from the following location:

    jar:file:/application/BOOT-INF/lib/springdoc-openapi-starter-common-3.0.1.jar!/org/springdoc/core/providers/ObjectMapperProvider.class

The called method's class, io.swagger.v3.core.util.Json31, is available from the following locations:

    jar:file:/application/BOOT-INF/lib/swagger-core-jakarta-jackson-3-52d4c245bb-1.jar!/io/swagger/v3/core/util/Json31.class
    jar:file:/application/BOOT-INF/lib/swagger-core-jakarta-2.2.41.jar!/io/swagger/v3/core/util/Json31.class

The called method's class hierarchy was loaded from the following locations:

    io.swagger.v3.core.util.Json31: file:/application/BOOT-INF/lib/swagger-core-jakarta-jackson-3-52d4c245bb-1.jar


Action:

Correct the classpath of your application so that it contains compatible versions of the classes org.springdoc.core.providers.ObjectMapperProvider and io.swagger.v3.core.util.Json31

@vpelikh

vpelikh commented Feb 17, 2026

Copy link
Copy Markdown
Contributor Author

@daniel-kmiecik @Mattias-Sehlstedt @ewaostrowska, hey! I see you've done the last commits to this repository. Can anyone check out this PR?

@Mattias-Sehlstedt

Copy link
Copy Markdown
Contributor

Hi @vpelikh, I am only a contributor, so I can unfortunately not do anything to help. But the other two are maintainers and will hopefully assist you.

@piotrooo

Copy link
Copy Markdown

@MichakrawSB Is there any ETA for this feature? Can we please prioritize this?

@KP-EV

KP-EV commented Mar 4, 2026

Copy link
Copy Markdown

It would be really great if you could prioritize this 🙏

@fenston

fenston commented Mar 24, 2026

Copy link
Copy Markdown

Is this PR not progressing?

@lordarnoud

Copy link
Copy Markdown

Any information on this yet? Will this also make it work with the newest springboot and java 26?

@jochenberger

Copy link
Copy Markdown
Contributor

I'm running the current version with latest Spring Boot/Jackson 3 on Java 26 without issues.

@piotrooo

Copy link
Copy Markdown

I'm running the current version with latest Spring Boot/Jackson 3 on Java 26 without issues.

Yes, it works. However, you probably need to add Jackson 2 compatibility support using the deprecated classes. It does work, but it is not an ideal solution.

@mzhafez

mzhafez commented Apr 15, 2026

Copy link
Copy Markdown

Is there any plan on merging this or maybe adding this to the next major version instead?

@lbenedetto

Copy link
Copy Markdown

Going to be forced to ditch swagger and find another solution soon 😅

Spring Boot 3.5.x OSS Support (End of Life) ends on June 30, 2026. After this date, community-driven security patches and bug fixes will cease.

@BranislavMalo

Copy link
Copy Markdown

Hey, any update on this?

this has been open since january 1st and there’s a lot of interest here compared to most PRs, but it’s still just sitting in “review required” while multiple releases went out

is this actually planned to be merged anytime soon or is it blocked on something?

@jochenberger

Copy link
Copy Markdown
Contributor

Yes, it works. However, you probably need to add Jackson 2 compatibility support using the deprecated classes.

No, you don't. Just upgrade Spring Boot and migrate your code to Jackson 3. As long as swagger-core depends on Jackson 2, they will pull it in and just use it.

I wonder how many people give up before even trying to do the update.

@zqq90

zqq90 commented Apr 23, 2026 •

Copy link
Copy Markdown

I'm running the current version with latest Spring Boot/Jackson 3 on Java 26 without issues.

@jochenberger

I suspect you might not have used certain annotations from the jackson-databind package, such as JsonNaming.

Or you may have added both Jackson 2 and Jackson 3 annotations at the same time during the migration.

For example:

@tools.jackson.databind.annotation.JsonNaming(tools.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy.class)
@com.fasterxml.jackson.databind.annotation.JsonNaming(com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy.class)
public class SampleVO {

If that's the case, it's really a nagging annoyance.

@jochenberger

Copy link
Copy Markdown
Contributor

Good point @zqq90, I'm indeed not using any of those.

@KP-EV

KP-EV commented May 6, 2026

Copy link
Copy Markdown

@ewaostrowska is it possible to prioritize this higher? Alot of teams are waiting for this :)

@gregjotau

Copy link
Copy Markdown

I resolved the current master conflicts and migrated the Jackson databind imports added since this branch was opened. Since I cannot push directly to the contributor fork, I opened vpelikh#127 into update-to-java-17.

Local validation is green:

  • full 21-module Maven install
  • BOM integration validation
  • Gradle plugin build and all 5 tests on Java 17

@DriesVanbilloen

Copy link
Copy Markdown

@djankows I think this is ready for the builds and review. Could you take a look? I am migrating to Jackson 3 for the projects in my company, and this is blocking.

Sorry to bother 😅

vpelikh added 2 commits July 23, 2026 19:36
changes:
- update maven-compiler-plugin to latest 3.14.1
- update maven-javadoc-plugin to latest 3.12.0
- update jacoco-maven-plugin to latest 0.8.14
- set maven.compiler.release to 17
- set source to 17 and update link to javadoc for maven-javadoc-plugin configuration
- set java-version to 17 in github workflows
- set java version to 17 in swagger-gradle-plugin
Signed-off-by: Vasily Pelikh <[email protected]>
@mschout

mschout commented Jul 28, 2026

Copy link
Copy Markdown

I'm using @vpelikh's fork in a project that I upgraded, and I ran into some significant schema drift regarding required fields. Posting my workaround here in case it helps others / can be fixed upstream

Essentially:

  • io.github.vpelikh:springdoc-openapi:4.0.0 ships a KotlinRequiredPropertyCustomizer which is registered as a ModelConverter, which runs over every model, it only skips java.* packages.
  • For a Java class, Kotlin reflection sees platform types, and KType.isMarkedNullable(), so every property of every Java DTO gets marked required.
  • In our app this caused an unintended expansion of the required fields in 142 of 150 schemas.

The workaround was to:

in application.yaml:

Turn off the automatic KotlinRequiredPropertyCustomizer:

springdoc:
  enable-kotlin: false

And then re-register KotlinNullablePropertyCustomizer manually in a @Configuration class like this:

/**
 * Takes over Kotlin model introspection from springdoc, which is switched off via
 * {@code springdoc.enable-kotlin=false}.
 *
 * <p>
 * springdoc's own ModelResolver is built from swagger's static mapper without
 * jackson-module-kotlin, so Kotlin types are introspected as plain Java beans and lose
 * their {@code required} markers. {@link #kotlinAwareModelResolver} mirrors springdoc's
 * construction and adds the Kotlin module, which restores them.
 */
@Configuration
class KotlinAwareModelResolverConfiguration {

  @Bean
  ModelResolver kotlinAwareModelResolver(SpringDocConfigProperties properties) {
    var openapi31 = properties.isOpenapi31();
    var base = openapi31 ? Json31.mapper() : Json.mapper();

    var mapper = SpringDocHalJacksonModuleUtils.configureHalOnBuilder(
      base.rebuild()
        .addModule(new SpringDocSealedClassModule())
        .addModule(new KotlinModule.Builder().build()))
      .build();

    return new ModelResolver(mapper).openapi31(openapi31);
  }

  /**
   * Re-registers the half of springdoc's Kotlin support we still want.
   *
   * <p>
   * Disabling {@code springdoc.enable-kotlin} also drops
   * {@code KotlinRequiredPropertyCustomizer}, which is the reason it is disabled: new in
   * springdoc 4, it runs Kotlin reflection over every resolved model rather than only
   * Kotlin ones. A Java class's properties come back as platform types, and
   * {@code KType.isMarkedNullable()} is false for those, so it marks every property of
   * every Java DTO {@code required}. {@link #kotlinAwareModelResolver} already infers
   * Kotlin {@code required} correctly, so nothing is lost by leaving it out — but the
   * nullable marking has no equivalent, so it is registered here.
   */
  @Bean
  KotlinNullablePropertyCustomizer kotlinNullablePropertyCustomizer(ObjectMapperProvider objectMapperProvider) {
    return new KotlinNullablePropertyCustomizer(objectMapperProvider);
  }
}

@vpelikh

vpelikh commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

@mschout thanks for bug report. Just released new version 5.0.3 with fix.
Next time create issues at https://github.com/vpelikh/springdoc-openapi please, so this PR don't get flooded.

@BranislavMalo

Copy link
Copy Markdown

Hi @djankows and @ewaostrowska, could we please get some concrete feedback on this PR?

This has been open since January, has received multiple follow-ups from the community, and yet there still doesn't seem to be any clear indication of whether or when it will be reviewed.

Jackson 3 support is no longer just a nice-to-have — it is becoming increasingly relevant as projects move towards Spring Boot 4. At this point, repeatedly asking for an update without getting any response is honestly getting a bit frustrating.

Could one of you please take a look, or at least let us know what is blocking this PR and whether there is a realistic path towards getting it merged?

Even a clear "we're not going to work on/review this right now" would be more useful than continued silence.

Thanks.

@danielhultqvist

Copy link
Copy Markdown

@daniel-kmiecik Any chance that you can take a look at this PR?

@YOU54F

YOU54F commented Sep 9, 2026

Copy link
Copy Markdown

Hey @vpelikh,

We appreciate the contribution, a member of the team will be reviewing this shortly,

We have posted a full reply in the linked issue

#4991 (comment)

Many thanks,

Yousaf

@vpelikh

vpelikh commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

@YOU54F, thank you for the feedback. I really appreciate that the team is ready to start reviewing.

Before you dive in, I would like to bring this PR up to date – resolve conflicts with the current master, update dependencies, double‑check that all tests pass, and also incorporate any changes that may have been missed from my fork. I will do this shortly and let you know when the PR is fully ready for review.

@vpelikh
vpelikh marked this pull request as draft September 9, 2026 09:23
@YOU54F

YOU54F commented Sep 9, 2026

Copy link
Copy Markdown

Many thanks Vasily, we look forward to it 🙌🏾

@daniel-kmiecik

daniel-kmiecik commented Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator

@vpelikh, please hold on. We've already been working on top of your changes on a separate branch here. We rebased your commits, resolved all merge conflicts, and then performed a thorough migration review.

The review confirmed that the core migration is solid. All tests pass, serializers/deserializers and coordinates were faithfully migrated. However, it uncovered issues stemming mainly from Jackson 3's changed defaults and removed APIs that weren't fully compensated across all mapper factory methods. We fixed issues, added regression tests for each, and did some code quality improvements.

We still need some time to verify that all Jackson 3 behavioral changes are fully accounted for in the codebase. Additionally, moving from Jackson 2 to 3 along with the Java version bump requires a new major release, which also means adjustments to our CI/CD pipelines.

I'll close this PR shortly and open ours. Your contribution will of course be credited in the commits. Thank you for driving the initial migration work. We also apologize for the long wait on picking this up. Yousaf has already explained the reasons in his message.

@vpelikh

vpelikh commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor Author

@daniel-kmiecik, thank you for the detailed update and for letting me know. I will wait for team's PR. Feel free to close this one.

@daniel-kmiecik

daniel-kmiecik commented Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator

@vpelikh as I wrote above I'm closing this PR and opening a new one based on your contribution #5314

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Support Jackson 3.x release line