Skip to content

Commit

Permalink
Process the JSON in the "anyOf" array
Browse files Browse the repository at this point in the history
  • Loading branch information
luandy64 committed Nov 25, 2019
1 parent d3b65f4 commit ea75869
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions scripts/tap-generate-docs/src/tap_generate_docs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@
"description" ""}]
(cond (= "object" (property-json-schema-partial "type"))
(if (nil? (property-json-schema-partial "properties"))
(throw (ex-info "Found object type without properties defined: " {:property-name property-name}))
(throw (ex-info "Found object type without properties defined: " {:property-name property-name
:property property
:schema schema}))
(assoc base-converted-property
"subattributes"
(convert-object-properties tap-fs schema (property-json-schema-partial "properties"))))
Expand Down Expand Up @@ -209,7 +211,8 @@
"multiary-type = a property that _may_ have more than one type."
[tap-fs schema [property-name property-json-schema-partial
:as property]]
(let [property (if (contains? property-json-schema-partial "$ref")
(let [found-anyOf (contains? property-json-schema-partial "anyOf")
property (if (contains? property-json-schema-partial "$ref")
(let [{:keys [file json-pointer]}
(parse-json-schema-reference
(property-json-schema-partial "$ref"))
Expand Down Expand Up @@ -237,8 +240,12 @@
:schema schema})))
[property-name referenced-json-schema-partial])
property)]
(let [unary-type-properties
(property->unary-type-properties property)
(let [unary-type-properties (if found-anyOf
(filter not-empty
(first (map property->unary-type-properties
(map #(conj [property-name] %)
(property-json-schema-partial "anyOf")))))
(property->unary-type-properties property))

converted-unary-type-properties
(map (partial convert-unary-type tap-fs schema)
Expand Down

0 comments on commit ea75869

Please sign in to comment.