Fork me on GitHub
#clojure-spec
<
2016-11-14
>
ikitommi06:11:18

When creating custom Specs, what are the rules for describe*? eval’ing it should return the Spec?

ikitommi06:11:25

Could the describe* of Specs be used as a serialization format over the wire (sending specs over Transit etc.)?

Alex Miller (Clojure team)13:11:35

You should call s/form

Alex Miller (Clojure team)13:11:16

That is intended to be a form that can serialized a wire (all symbols should be resolved etc)

Alex Miller (Clojure team)13:11:47

There are a number of known bugs and patches on it that I have been working through so it's not 100% yet

Alex Miller (Clojure team)13:11:18

s/form uses describe* internally but you shouldn't call that directly

ikitommi14:11:03

thanks @alexmiller and great to hear the serialization support in the scope of spec!

hiredman20:11:50

I wrote some code the other day that uses s/form to traverse specs and generates a json schema from the spec, it was way cool

hiredman21:11:03

I can't, but it is a lot like a lisp interpreter, type dispatch + dispatch on the first symbol in a seq

hiredman21:11:00

if you see a keyword, call s/form to lookup the spec, if you get a seq, dispatch on the first symbol in the seq (s/keys, s/or, whatever) if you get a symbol it is some kind of type predicate like uuid? and you map that to some type in json