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

LocalTime, YearMonth, MonthDay are not serialized correctly in ISO 8601 format #2938

Closed
redblackblossom opened this issue Mar 11, 2025 · 0 comments

Comments

@redblackblossom
Copy link

redblackblossom commented Mar 11, 2025

Describe the bug

Issue: The Swagger API specification generates incorrect request body examples when the RequestBody contains LocalTime, YearMonth, or MonthDay. The generated format does not comply with ISO 8601, displaying unexpected fields and values.

To Reproduce

version
java version : 17
springboot version : 3.4.3
Springdoc OpenAPI version : org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.5
lombok version : 1.18.36

TestController

@PostMapping("/time1")
public TimeDtoNoAnnotations postTime1(@RequestBody TimeDtoNoAnnotations timeDto) {
	return timeDto;
}
@Builder
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class TimeDtoNoAnnotations {
	LocalDateTime localDateTime;
	LocalDate localDate;
	LocalTime localTime;
	YearMonth yearMonth;
	MonthDay monthDay;
	Year year;
}

Swagger default request body (incorrect behavior)
Image

Swagger default example (Try it out result)
Image

The value 1073741824 is 2³⁰, but its presence in the request body is unclear.

Expected output (correct ISO 8601 format)

Image

Image

Additional context
If this issue is still open and needs a fix, I would love to contribute. Please let me know if I can work on this.

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

No branches or pull requests

1 participant