0

I use Spring Boot 2.4.5, springdoc-openapi-ui 1.5.7,

My Entity has fields:

private LocalDate beginDate;
private LocalTime beginTime;

Request body

This option does not work

{
"beginDate": "2021-04-25",
  "beginTime": {
    "hour": 0,
    "minute": 0,
    "second": 0,
    "nano": 0
}

And this worker

{
"beginDate": "2021-04-25",
"beginTime": "00:00:00"
}

I tried various field annotations and adding dependencies, but I got a 400 or 500 error.

I see two possible solutions:

  1. configure the schema display in Swagger " 00:00:00"
  2. properly process the json with the painted components

Thank you in advance for your help!

1 Answers1

0

Thats because you need to define a deserializer so, that your request can be properly handled when passing 4 fields (hour/min/sec/nano) instead of just a single String field.

@JsonDeserialize(using = LocalTimeDeserializer.class)
private LocalTime beginTime;

you may also want to consider using this feature on your ObjectMapper when writing your deserialization class.

ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
duppydodah
  • 165
  • 1
  • 3
  • 17