Skip to content

Commit

Permalink
dirty
Browse files Browse the repository at this point in the history
  • Loading branch information
frenchy64 committed Apr 11, 2024
1 parent 7fd059a commit 6d0c185
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/ring/swagger/json_schema_dirty.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@

(extend-protocol json-schema/JsonSchema
schema.experimental.abstract_map.AbstractSchema
(convert [e {:keys [properties? schema-type]
:or {properties? true}} ]
(convert [e {:keys [properties?]
:or {properties? true} :as options}]
(if properties?
(merge {:discriminator (name (:dispatch-key e))}
(json-schema/->swagger (:schema e) {:properties? properties? :schema-type schema-type}))
(json-schema/reference e schema-type)))
(json-schema/->swagger (:schema e) (assoc options :properties? properties?)))
(json-schema/reference e options)))

schema.experimental.abstract_map.SchemaExtension
(convert [e {:keys [schema-type] :as options}]
{:allOf [(json-schema/->swagger (:base-schema e) {:properties? false :schema-type schema-type})
(convert [e options]
{:allOf [(json-schema/->swagger (:base-schema e) (assoc options :properties? false))
; Find which keys are also in base-schema and don't include them in these properties
(json-schema/->swagger (let [base-keys (set (keys (:schema (:base-schema e))))
m (:extended-schema e)]
(into (empty m) (remove (comp base-keys key) m)))
{:properties? true :schema-type schema-type})]}))
(assoc options :properties? true))]}))

0 comments on commit 6d0c185

Please sign in to comment.