Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with DateTime formatting after upgrading to springdoc-openapi-starter-webmvc-ui version 2.8.6 #2956

Closed
Skumbriy opened this issue Apr 1, 2025 · 2 comments

Comments

@Skumbriy
Copy link

Skumbriy commented Apr 1, 2025

Description:

After upgrading to springdoc-openapi-starter-webmvc-ui version 2.8.6, we noticed that OffsetDateTime values are no longer properly formatted in the Swagger UI. Instead of displaying the date-time in the expected format, we are now seeing Unix timestamp values.

Here is the relevant information for reproducing the issue:

pom.xml

org.springdoc springdoc-openapi-starter-webmvc-ui 2.8.6 Java DTO Class:

import org.springframework.format.annotation.DateTimeFormat;
import java.time.OffsetDateTime;
import org.springframework.lang.Nullable;

public class ExampleDTO {

@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
private @Nullable OffsetDateTime createdAt;

@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
private @Nullable OffsetDateTime updatedAt;

}

Expected Behavior (with version 2.8.5):

In Swagger UI, the createdAt and updatedAt fields should display the OffsetDateTime in the following format:

"createdAt": "2022-12-02T14:14:32+01:00",
"updatedAt": "2022-12-02T14:14:41+01:00"
Actual Behavior (with version 2.8.6):

After the upgrade to springdoc-openapi-starter-webmvc-ui version 2.8.6, the createdAt and updatedAt fields are displayed as Unix timestamps, rather than formatted OffsetDateTime values. The Swagger UI shows:

"createdAt": 1669986872,
"updatedAt": 1669986881
Steps to Reproduce:

Upgrade springdoc-openapi-starter-webmvc-ui to version 2.8.6.
Define a DTO with OffsetDateTime fields as shown above.
Open the Swagger UI or check the OpenAPI documentation.
Observe that the createdAt and updatedAt fields are displayed as Unix timestamps instead of the expected formatted date-time string.
Additional Information:

The issue did not occur with version 2.8.5 of springdoc-openapi-starter-webmvc-ui, where the date-time fields were correctly formatted.
We are using the @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) annotation for formatting the OffsetDateTime fields.
Suggested Solution:

It seems that the change in behavior might be related to how Springdoc OpenAPI is handling date-time formatting in version 2.8.6. We would expect that OffsetDateTime values should be automatically formatted as ISO 8601 date-time strings instead of Unix timestamps.

@Mattias-Sehlstedt
Copy link

Hi, looks like something that might be tied to the same issue as this? So might be that the fix would be to extend the fix that was done for that issue here?

@bnasslahsen
Copy link
Collaborator

@Skumbriy,

Not reproducible.
Feel free to provide a Minimal, Reproducible Example - with HelloController that reproduces the problem.

This ticket will be closed, but can be reopened if your provide the reproducible sample.

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

No branches or pull requests

3 participants