Skip to content

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

Closed
@redblackblossom

Description

@redblackblossom

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions