a guest Oct 16th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defn- schema->type
  2.   [schema]
  3.   (let [types (concat
  4.                (m/search schema
  5.                  {"format" "date-time"}           :db.type/instant
  6.                  {"format" "uri"}                 :db.type/uri
  7.                  {"type"   "array"}               '(Array nil)
  8.                  {"type"   "boolean"}             :db.type/boolean
  9.                  {"type"   "integer"}             :db.type/long
  10.                  {"type"   "string"}              :db.type/string
  11.                  {"items"  (m/pred some? ?item)}  (list 'Array (schema->type ?item))
  12.                  {"$ref"   (m/pred some? ?ref)}   (if (= ?ref "#uuid")
  13.                                                     :db.type/uuid
  14.                                                     (subs ?ref 1)))
  15.                (map schema->type (get schema "allOf")))]
  16.     (reduce narrower-type nil types)))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand