Fork me on GitHub
#ring-swagger
<
2017-08-03
>
henrik11:08:39

I’m causing myself problems by using clj-time to encode timestamps in my server responses:

Caused by: java.lang.IllegalArgumentException: No implementation of method: :packable-pack of protocol: #'msgpack.core/Packable found for class: org.joda.time.DateTime
I haven´t fully wrapped my head around coercions yet. Is this something I should handle manually before sending the response back to the API endpoint, or could I set up a coercion to convert the timestamp into a string?

ikitommi12:08:11

@henrik With msgpack think you need to write a extension to support joda dates directly, like this: https://github.com/edma2/clojure-msgpack/blob/master/src/msgpack/clojure_extensions.clj

ikitommi12:08:41

coercion is normally used to widen the types, eg from string -> keyword|date|...

ikitommi12:08:02

there could be a custom coercion to do the opposite (date->string, keyword->string), but normally this is done by the format encoder

ikitommi12:08:32

we actually dropped msgpack & yaml from the default settings in the latest alpha (easy to put back) as they don't provide support for all common types.

henrik15:08:09

@ikitommi Gotcha, thank you!

henrik15:08:18

Did you? As of alpha 6, they seem to be in there.

henrik15:08:23

Ah, we’re at alpha 7 now.

henrik15:08:44

I thought it was pretty cool to find that yaml of all things was supported out of the box. Makes sense though, if the format is lacking.