diff --git a/pyproject.toml b/pyproject.toml index 42d362a..4a40e8d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=61.0"] build-backend = "setuptools.build_meta" [project] name = "formatron" -version = "0.4.5" +version = "0.4.6" authors = [ {name = "Xintong Sun", email = "xs28@rice.edu"}, ] diff --git a/src/formatron/formats/json.py b/src/formatron/formats/json.py index f365f06..cd16c60 100644 --- a/src/formatron/formats/json.py +++ b/src/formatron/formats/json.py @@ -440,6 +440,9 @@ def __init__(self, nonterminal: str, capture_name: typing.Optional[str], schema: - typing.Any - Subclasses of collections.abc.Mapping[str,T] and typing.Mapping[str,T] where T is a supported type, - Subclasses of collections.abc.Sequence[T] and typing.Sequence[T] where T is a supported type. + - optionally with `minItems`, `maxItems`, `prefixItems` constraints + - *Warning*: too large difference between minItems and maxItems can lead to very slow performance! + - *Warning*: By json schema definition, prefixItems by default allows additional items and missing items in the prefixItems, which may not be the desired behavior and can lead to very slow performance if prefixItems is long! - tuple[T1,T2,...] where T1,T2,... are supported types. The order, type and number of elements will be preserved. - typing.Literal[x1,x2,...] where x1, x2, ... are instances of int, string, bool or NoneType, or another typing.Literal[y1,y2,...] - typing.Union[T1,T2,...] where T1,T2,... are supported types. diff --git a/src/formatron/schemas/json_schema.py b/src/formatron/schemas/json_schema.py index f799c24..3dd6fef 100644 --- a/src/formatron/schemas/json_schema.py +++ b/src/formatron/schemas/json_schema.py @@ -54,6 +54,7 @@ def create_schema(schema: dict[str, typing.Any], registry=Registry()) -> schemas - `minLength, maxLength, pattern` keywords for string type - `minimum, maximum, exclusiveMinimum, exclusiveMaximum` keywords for number type and integer type - `items` keyword + - optionally with `minItems`, `maxItems`, `prefixItems` constraints - `properties` keyword - Due to implementation limitations, we always assume `additionalProperties` is false. - `enum` and `const` keyword