[Fix] Allow closed object schemas in Outlines prevalidation (#39869)
This commit is contained in:
@@ -224,17 +224,20 @@ def validate_outlines_json_schema(schema: Any) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if "properties" in subschema:
|
if "properties" in subschema:
|
||||||
ignored_object_constraints = sorted(
|
ignored_object_constraints = {
|
||||||
{"additionalProperties", "maxProperties", "minProperties"}.intersection(
|
"additionalProperties",
|
||||||
subschema
|
"maxProperties",
|
||||||
)
|
"minProperties",
|
||||||
)
|
}.intersection(subschema)
|
||||||
|
if subschema.get("additionalProperties") is False:
|
||||||
|
# The properties regex already excludes undeclared keys.
|
||||||
|
ignored_object_constraints.discard("additionalProperties")
|
||||||
if ignored_object_constraints:
|
if ignored_object_constraints:
|
||||||
_raise_unsupported(
|
_raise_unsupported(
|
||||||
"outlines",
|
"outlines",
|
||||||
pointer,
|
pointer,
|
||||||
"properties cannot be combined with "
|
"properties cannot be combined with "
|
||||||
+ ", ".join(ignored_object_constraints),
|
+ ", ".join(sorted(ignored_object_constraints)),
|
||||||
)
|
)
|
||||||
|
|
||||||
if "prefixItems" in subschema:
|
if "prefixItems" in subschema:
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ class TestOutlinesJSONSchemaValidation(unittest.TestCase):
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
"required": ["name"],
|
"required": ["name"],
|
||||||
|
"additionalProperties": False,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -155,7 +156,7 @@ class TestOutlinesJSONSchemaValidation(unittest.TestCase):
|
|||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {"name": {"type": "string"}},
|
"properties": {"name": {"type": "string"}},
|
||||||
"additionalProperties": False,
|
"additionalProperties": True,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "array",
|
"type": "array",
|
||||||
|
|||||||
Reference in New Issue
Block a user