Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
frenchy64 committed Dec 19, 2024
1 parent 4473136 commit fa844b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/flanders/json_schema.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
;; fields e.g., {"minimum": 1, "required": ["a"]} => [:or [:int {:min 1}] [:map [:a :any]]]
:else (or (when ->infer-type
(->infer-type v opts))
(unsupported-schema! "cannot infer type, please set ::->default-type" v opts))))
(unsupported-schema! "cannot infer type" v opts))))
_ (check-unsupported-keys! v opts)
opts (update opts ::dialect #(or $schema %))
_ (assert (nil? $anchor)) ;; TODO
Expand Down
9 changes: 5 additions & 4 deletions test/flanders/json_schema_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@

;; examples

(defn infer-any [v _opts] (assoc v "type" ::sut/any))
(def security-finding-json (delay (json/decode (slurp (io/resource "security-finding.json")))))
(def FlandersSecurityFinding (delay (sut/->flanders @security-finding-json {::sut/->infer-type (fn [v _opts] (assoc v "type" ::sut/any))})))
(def FlandersSecurityFinding (delay (sut/->flanders @security-finding-json {::sut/->infer-type infer-any})))
(def example-SecurityFinding (delay (fe/->example-tree @FlandersSecurityFinding)))
(def SchemaSecurityFinding (delay (->schema @security-finding-json)))
(def MalliSecurityFinding (delay (->malli @security-finding-json)))
(def MalliSecurityFinding-no-example (delay (->malli @security-finding-json {:flanders.malli/no-example true})))
(def SchemaSecurityFinding (delay (->schema @security-finding-json {::sut/->infer-type infer-any})))
(def MalliSecurityFinding (delay (->malli @security-finding-json {::sut/->infer-type infer-any})))
(def MalliSecurityFinding-no-example (delay (->malli @security-finding-json {:flanders.malli/no-example true ::sut/->infer-type infer-any})))

;; tests

Expand Down

0 comments on commit fa844b3

Please sign in to comment.