Fork me on GitHub
#ring-swagger
<
2017-04-26
>
plins14:04:08

hello everyone, i know its possible to do a custom coercer in Schema, but before digging in to that id like to make sure there isnt any stanrdart way of doing it... is there any easy documented way of specifying a field inside a :body-params vector a datetime or date format?

juhoteperi15:04:41

@plins You mention :body-params so I guess you want to coerce string from JSON to DateTime or Date? Ring-swagger has built-in coercion for this

plins15:04:27

guess i was looking at compojure-api docs, thank you! 🙂

juhoteperi15:04:53

the table at ring-swagger readme defines the supported classes/schemas https://github.com/metosin/ring-swagger#out-of-the-box-supported-schema-elements

juhoteperi15:04:11

No java8 dates currently, but jodatime is supported

juhoteperi15:04:12

Oh, in fact ring-swagger supports java 8 but the readme is not updated

plins15:04:51

oh this is nice, cause i was going for a custom formatter because im using java 8 format dates, should i just use the class name in the right hand operator like

:body-params [mydate :- java.time.LocalDate] 
?

juhoteperi16:04:03

@plins Yeah, that should work

plins16:04:21

after I succeed, should I update the README of ring-swagger to include a java8 example?

juhoteperi16:04:37

I updated the table in readme to mention java8

plins16:04:42

is it possible to pass also a date format? like "dd/mm/yyyy"?

juhoteperi16:04:57

Nope, only iso8601 formats are supported

mtkp16:04:29

the built in coercer just uses java.time.LocalDate/parse

juhoteperi17:04:34

Yeah, and by default is uses iso8601 format, yyyy-mm-dd