This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-05-27
Channels
- # aws (7)
- # babashka (145)
- # beginners (83)
- # calva (18)
- # cider (11)
- # clara (9)
- # clj-kondo (59)
- # cljdoc (4)
- # cljs-dev (4)
- # cljsrn (11)
- # clojure (168)
- # clojure-australia (21)
- # clojure-dev (5)
- # clojure-europe (46)
- # clojure-italy (3)
- # clojure-nl (10)
- # clojure-taiwan (1)
- # clojure-uk (55)
- # clojurescript (85)
- # clojureverse-ops (1)
- # code-reviews (3)
- # conjure (22)
- # cursive (3)
- # datahike (3)
- # datomic (4)
- # emacs (5)
- # helix (20)
- # jackdaw (1)
- # jobs (2)
- # jobs-discuss (7)
- # lsp (1)
- # malli (5)
- # off-topic (85)
- # other-languages (4)
- # practicalli (4)
- # reitit (2)
- # releases (2)
- # sci (62)
- # shadow-cljs (181)
- # testing (5)
- # tools-deps (15)
- # xtdb (31)
I'm looking at JSON Schema now and trying to write it out with malli and recursive schemas (with the intention of writing a transformer from it to malli) I'm using this BNF as reference https://cswr.github.io/JsonSchema/spec/grammar/ I'm wondering what's the best schema to pick for modelling it A lot of it is defined in terms of key-value pairs I thought I'd try modelling it as a union for convenience I defined
(defn -ref-u [& args] (into [:union] (map (fn [k] [:ref k])) args))
Then
;; JSDoc := { ( id, )? ( defs, )? JSch }
;; id := "id": "uri"
;; defs := "definitions": { kSch (, kSch)*}
;; kSch := kword: { JSch }
Becomes
::JSDoc (-ref-u ::id ::defs ::JSch)
::id [:map [:id {:optional true} [:ref ::uri]]]
::defs [:map [:definitions {:optional true} [:map-of :keyword [:ref ::JSch]]]]
But when it comes to n>=1 map schemas which are one-of types, I'm stumped
;; JSch := ( res (, res)*)
i.e., the map should have at least one res
where it's defined as
;; res := type | strRes | numRes | arrRes | objRes | multRes | refSch | title | description
::res (-ref-u ::type ::strRes ::numRes ::arrRes ::objRes ::multRes ::refSch ::title ::description)
Ideally, I'd want some schema between map-of
and map
I'm also not 100% clear on the difference between union and merge and if they're even the right choice.
Should I perhaps customize a -collection-schema
?Is this a standard? https://jsonlogic.com/