Skip to content

fix(kotlin-spring): use correct Jackson 3 property path for WRITE_DATES_AS_TIMESTAMPS#23384

Open
takkiraz wants to merge 2 commits intoOpenAPITools:masterfrom
takkiraz:fix/kotlin-spring-jackson3-datetime-property
Open

fix(kotlin-spring): use correct Jackson 3 property path for WRITE_DATES_AS_TIMESTAMPS#23384
takkiraz wants to merge 2 commits intoOpenAPITools:masterfrom
takkiraz:fix/kotlin-spring-jackson3-datetime-property

Conversation

@takkiraz
Copy link
Copy Markdown
Contributor

@takkiraz takkiraz commented Mar 27, 2026

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work.
  • Run the following to build the project and update samples
  • File the PR against the correct branch: master
  • If your PR solves a reported issue, reference it using GitHub's linking syntax

Fixes #23383

Summary

When using Spring Boot 4 with Jackson 3, the generated application.yaml contains an invalid property path that causes the application to fail at startup:

Failed to bind properties under 'spring.jackson.serialization' to java.util.Map<tools.jackson.databind.SerializationFeature, java.lang.Boolean>:

Reason: No enum constant tools.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS

Root cause: In Jackson 3.x, WRITE_DATES_AS_TIMESTAMPS was moved from SerializationFeature to DateTimeFeature. The Spring Boot property path changed from:

  • Jackson 2.x: spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS
  • Jackson 3.x: spring.jackson.datatype.datetime.WRITE_DATES_AS_TIMESTAMPS

Changes

  • Updated kotlin-spring template to use conditional logic based on useSpringBoot4 flag
  • Updated kotlin-springboot-4 sample with correct property path
  • Added tests to verify correct property path for both Spring Boot 3 and Spring Boot 4

This aligns the kotlin-spring generator with the existing behavior in the JavaSpring generator.

How to validate

  1. Generate a kotlin-spring server with Spring Boot 4:

    openapi-generator-cli generate -g kotlin-spring -i petstore.yaml -o out \
      --additional-properties=useSpringBoot4=true,useJackson3=true
  2. Check out/src/main/resources/application.yaml contains:

    jackson:
      datatype:
        datetime:
          WRITE_DATES_AS_TIMESTAMPS: false
  3. Run the server:

    cd out && ./gradlew bootRun
  4. Server should start successfully

Technical Committee

@cachescrubber @DKoyama @jmini @shibasis0801 @welshm @Zomzog


Summary by cubic

Fixes a startup failure in kotlin-spring Spring Boot 4 projects by generating the correct Jackson 3 path for WRITE_DATES_AS_TIMESTAMPS. Aligns behavior with JavaSpring. Fixes #23383.

  • Bug Fixes
    • Use spring.jackson.datatype.datetime.WRITE_DATES_AS_TIMESTAMPS when useSpringBoot4=true (Jackson 3).
    • Keep spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS for Spring Boot 3 (Jackson 2).
    • Updated application.mustache, sample application.yaml, and added tests to verify the correct path and ensure the other path is absent.

Written for commit 68a77f1. Summary will update on new commits.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

…ES_AS_TIMESTAMPS

When using Spring Boot 4 with Jackson 3, the property path for
WRITE_DATES_AS_TIMESTAMPS changed from:
  spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS
to:
  spring.jackson.datatype.datetime.WRITE_DATES_AS_TIMESTAMPS

This fix adds conditional logic to the kotlin-spring generator template
to use the correct property path based on useSpringBoot4 flag, matching
the behavior already implemented in the JavaSpring generator.

Fixes binding error:
'Failed to bind properties under spring.jackson.serialization to
java.util.Map<tools.jackson.databind.SerializationFeature, java.lang.Boolean>:
No enum constant tools.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS'
Add tests to verify that:
- Spring Boot 4 generates application.yaml with spring.jackson.datatype.datetime.WRITE_DATES_AS_TIMESTAMPS
- Spring Boot 3 generates application.yaml with spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS
@takkiraz takkiraz force-pushed the fix/kotlin-spring-jackson3-datetime-property branch from 9fc0641 to 68a77f1 Compare March 27, 2026 23:09
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.

[BUG][kotlin-spring] Spring Boot 4 fails to start: WRITE_DATES_AS_TIMESTAMPS not found in Jackson 3 SerializationFeature

1 participant