Skip to content

feat: add spring-boot4 library with Jackson 3 support - #1438

Open
daniel-kmiecik wants to merge 4 commits into
masterfrom
add-spring-boot-4-template-with-jackson-3
Open

daniel-kmiecik wants to merge 4 commits into
masterfrom
add-spring-boot-4-template-with-jackson-3

Conversation

@daniel-kmiecik

@daniel-kmiecik daniel-kmiecik commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request

Thank you for contributing to swagger-codegen-generators!

Please fill out the following checklist to help us review your PR efficiently.


Description

Summary

Adds an opt-in spring-boot4 library to the Spring generator for Spring Boot 4 / Spring Framework 7. The generated code uses Jackson 3 (tools.jackson.*), which is the default in Spring Boot 4. The default library and the existing spring-boot, spring-boot3 and spring-mvc outputs are not changed by this PR, apart from the shared template and AbstractJavaCodegen edits listed below.

What changed

  • New library spring-boot4 (SpringCodegen, libraries/spring-boot4/): Boot parent, spring-boot-starter-webmvc, springdoc, jackson-databind-nullable with JsonNullableJackson3Module, and a JacksonModule bean.
  • Version options:
    • springBoot4Version: 4.0.9 or 4.1.3, default 4.1.3.
    • springBoot4JavaVersion: 17 or 21, default 21, written to maven.compiler.release.
    • springdoc is mapped from the Boot version: 4.0.x gets 3.0.3, everything else gets 3.2.0. springdoc 3.2.0 declares support only up to Boot 4.1.x.
  • Java 8+ code shape forced on for spring-boot4: java8 is always set, since Boot 4 requires Java 17+. Generated API interfaces carry default methods with example code, and controllers stay thin.
  • Shared templates (api, apiController, apiDelegate, model): imports and exception handling use {{jacksonDatabindPackage}}. Only spring-boot4 sets it to tools.jackson. Jackson annotations (com.fasterxml.jackson.annotation.*) stay unchanged, since Jackson 3 uses the same package.
  • AbstractJavaCodegen: jacksonDatabindPackage defaults to com.fasterxml.jackson, so other generators keep their current imports.
  • Refactor in SpringCodegen: versionOption(), readVersion() and packageDir() helpers replace repeated option and path code. No behaviour change intended.
  • Tests: new spring-boot4 cases in SpringGeneratorCodegenTest, covering Jackson 3 output, the springdoc mapping and version overrides. SpringGeneratorTest clears the System properties it sets, which fixes order-dependent failures.

Notes for reviewers

  • The shared templates and AbstractJavaCodegen affect every Java and Spring generator.

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)

How to Test

Screenshots / Additional Context

@daniel-kmiecik
daniel-kmiecik force-pushed the add-spring-boot-4-template-with-jackson-3 branch from fbb196b to 46b624c Compare November 24, 2026 12:45
@daniel-kmiecik
daniel-kmiecik force-pushed the add-spring-boot-4-template-with-jackson-3 branch from 74ed696 to ad14446 Compare November 26, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants