This sub-module converts JSON schema to llguidance grammar.
It aims to either produce a grammar conformant to the JSON schema semantics (Draft 2020-12), or give an error, but see below for some known differences.
There are various limits on the size of the input schema and the resulting grammar. However, we've successfully processed schemas up to 4 MB in size.
Following JSON schema features are supported.
Core features:
anyOf
oneOf
- not supported right now, useanyOf
instead, issueallOf
- intersection of certain schemas is not supported right now$ref
- external/remote refs unsupportedconst
enum
type
- both single type and array of types- sibling keys - when schema has keywords in addition to
anyOf
,allOf
,$ref
, the result is intersection
Array features:
items
prefixItems
minItems
maxItems
Object features:
properties
- order of properties is fixed to the order in schemaadditionalProperties
required
String features:
minLength
maxLength
pattern
(though we always anchor them, issue)format
, with the following formats:date-time
,time
,date
,duration
,email
,hostname
,ipv4
,ipv6
,uuid
,
Number features (for both integer and number):
minimum
maximum
exclusiveMinimum
exclusiveMaximum
multipleOf
- order of object properties is fixed to the order provided in
properties
field of schema- note: the order of properties in schemas resulting from intersections (e.g., via
allOf
) is unstable and should not be relied upon.
- note: the order of properties in schemas resulting from intersections (e.g., via
- string
format
is enforced by default, with unrecognized or unimplemented formats returning errors