Open
Description
The README states that this:
(json-schema.infer/infer-strict
{:title "ent-1"})
{:things [{:quantity 1}]})
Will generate this:
{:$schema "http://json-schema.org/draft-07/schema#"
:title "ent-1"
:type :object
:additionalProperties false
:properties {"things" {:type :array
:items {:type :object
:additionalProperties false
:properties {"quantity" {:type :integer}}
:required ["quantity"]}}}
:required ["things"]}
However, for me, using version 0.4.1
, it generates this:
{:$schema "http://json-schema.org/draft-07/schema#",
:title "ent-1",
:type #{:object},
:additionalProperties false,
:properties {"things" {:type #{:array},
:items {:type #{:object},
:additionalProperties false,
:properties {"quantity" {:type #{:integer}}},
:required #{"quantity"}}}},
:required #{"things"}}
Notably, the types are sets, which gets correctly converted to JSON lists, and which is technically a valid schema but can cause issues. For example the OpenAI API doesn't recognize that format, it expects a single type rather than an array of types.
If there is only one type I would suggest making it a single value rather than an array.
Thanks for this library! The infer function is awesome!