Anybody knows how to format LocalTime in Springfox? Converting to ISO format works for LocalDate with this setting to ObjectMapper
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
But for LocalTime I'm still getting this in example and model of swagger-ui
"time": {
"hour": "string",
"minute": "string",
"nano": 0,
"second": "string"
}
I have read something that swagger spec do not use time format. Is this somewhat connected?
Springfox does not know anything about the serialization features used, nor is there a good way to ask Jackson to figure it out.
However, you can help springfox along by providing model substitution rules. These are basically a way to change the schema of the model that is rendered in the specificiation. In your case a date/time would be represented as a time stamp which is really a long
.
So in your Docket
you would add a directModelSubstitute
to substitute the LocalTime
with Long
:
docket.directModelSubstitute(LocalTime.class, Long.class)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With