https://kotlinlang.org logo
#http4k
Title
# http4k
m

MrNiamh

01/02/2022, 1:02 PM
Hey, is there a way to specify the format for a property of a dto in the OpenAPI json? E.g. I'm trying to make it specify a property
startDate
is a date. Currently in my swagger.json it has:
Copy code
"startDate": {
  "example": "2021-01-01",
  "description": null,
  "type": "string"
},
but (i think) i'm expecting:
Copy code
"startDate": {
  "example": "2021-01-01",
  "description": null,
  "type": "string",
  "format": "date"
},
I've defined my bidi lens as:
Copy code
BiDiMapping<String, LocalDate>({ LocalDate.parse(it) }, { it.format(DateTimeFormatter.ISO_LOCAL_DATE) })
d

dave

01/03/2022, 9:54 AM
Sorry - Unfortunately not out of the box, because the base lens actually doesn't know anything about the type - it's just a string as far as the renderer is concerned. It's possible that you could do something with annotations, but without building a custom renderer ... (And it's complicated enough! 😂)
m

MrNiamh

01/03/2022, 1:22 PM
Ah sad times, well I'll leave it for now then
thanks anywho
7 Views