Skip to content

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

@takkiraz

Description

@takkiraz

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
Description

When using the kotlin-spring generator with useSpringBoot4=true and useJackson3=true, the generated application fails to start with the following error:

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

Description:

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

    Reason: failed to convert java.lang.String to tools.jackson.databind.SerializationFeature (caused by java.lang.IllegalArgumentException: No enum constant tools.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)

Action:

Update your application's configuration. The following values are valid:

    CLOSE_CLOSEABLE
    EAGER_SERIALIZER_FETCH
    FAIL_ON_EMPTY_BEANS
    ...

Root Cause: In Jackson 3.x (used by Spring Boot 4), the WRITE_DATES_AS_TIMESTAMPS feature was moved from SerializationFeature to DateTimeFeature. The 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

The kotlin-spring generator template always outputs the Jackson 2.x path, even when useSpringBoot4=true.

Note: The JavaSpring generator already handles this correctly with conditional logic.

openapi-generator version

7.21.0 (also confirmed on latest master)

OpenAPI declaration file content or url

Any valid OpenAPI spec, minimal example:

openapi: 3.0.3
info:
  title: Test API
  version: 1.0.0
paths:
  /ping:
    get:
      operationId: ping
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
Generation Details
openapi-generator-cli generate \
  -i api.yaml \
  -g kotlin-spring \
  -o server \
  --additional-properties=useSpringBoot4=true,useJackson3=true
Steps to reproduce
  1. Generate a kotlin-spring server with useSpringBoot4=true
  2. Build the project: ./gradlew build
  3. Run the application: ./gradlew bootRun
  4. Application fails to start with the error above
Related issues/PRs
  • The JavaSpring generator already has the fix: it uses conditional logic based on useSpringBoot4 in modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/application.mustache
Suggest a fix

The template at modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/application.mustache needs conditional logic based on useSpringBoot4:

Current (broken):

spring:
  jackson:
    serialization:
      WRITE_DATES_AS_TIMESTAMPS: false

Expected:

spring:
  jackson:
{{#useSpringBoot4}}
    datatype:
      datetime:
        WRITE_DATES_AS_TIMESTAMPS: false
{{/useSpringBoot4}}
{{^useSpringBoot4}}
    serialization:
      WRITE_DATES_AS_TIMESTAMPS: false
{{/useSpringBoot4}}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions