This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-22
Channels
- # beginners (42)
- # boot (73)
- # cider (17)
- # clara (1)
- # cljs-dev (47)
- # cljsrn (9)
- # clojars (4)
- # clojure (241)
- # clojure-italy (11)
- # clojure-norway (5)
- # clojure-russia (93)
- # clojure-spec (28)
- # clojure-uk (32)
- # clojurescript (170)
- # core-async (20)
- # cursive (62)
- # data-science (2)
- # datomic (47)
- # dirac (4)
- # events (1)
- # funcool (12)
- # gsoc (1)
- # hoplon (59)
- # immutant (8)
- # lambdaisland (4)
- # luminus (3)
- # lumo (11)
- # off-topic (13)
- # om (81)
- # onyx (1)
- # pedestal (47)
- # planck (30)
- # re-frame (2)
- # reactive (1)
- # reagent (2)
- # ring-swagger (15)
- # rum (1)
- # slack-help (5)
- # specter (5)
- # testing (5)
- # uncomplicate (8)
- # untangled (16)
- # vim (71)
- # yada (16)
trying a new approach to generate json-schemas from specs, I have a registry of specs/preds -> json-schema forms that's a multimethod and that allows me to have some form of inheritance
Can you show an example? I'm not sure what json-schema is or how you convert from spec to json-schema.
does the end result look different than the spec-tools conversion? (also uses a multimethod, but no inheritance atm)
not sure, I didn't look into spec-tools internals too much. What do you mean by end result?
code is here, but here be dragons, it's wip: https://github.com/mpenet/spex/blob/master/src/clj/qbits/spex/json_schema.clj
mapped all the predicates that have a clojure.spec generator, with those “rules”, here: https://github.com/metosin/spec-tools/blob/master/src/spec_tools/json_schema.cljc
derive looks nice. should we at some point merge the working stuff into XYZ? would like to copy-paste the some of the missing mappings from Spex already.
it’s missing the Coercion
protocol (instead of dynamic conforming), after it I’m kinda happy with what tries to resolve. the “drop-extra-keys from maps” things etc.
the 2112 would be awesome, it’s messy without that. Just realized yesterday that one can use and
and or
with s/keys
...
these are different approaches really, spec-tools seems to wrap all specs with it's own types to add "metadata", coercion etc, I just force the user to register its specs (and provide some defaults) and don't bother with coercion at all at this level (imho these are 2 different things)
@yonatanel thanks!
yeah or/and in keys is a bit of a pita, not sure it's feasible to translate in json-schema
spec-tools doesn’t force to wrap into own records, JSON Schema is extracted from normal spec forms. Own records can be used to add metadata.