Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Objects Which are Unconstrained (No additionalProperties) in JSON Schemas #907

Merged
merged 1 commit into from
May 22, 2024

Conversation

lapp0
Copy link
Contributor

@lapp0 lapp0 commented May 20, 2024

Fixes #844

Problem:

We cannot create a pattern using build_regex_from_schema() using {"type": "object"} unless additionalProperties is set. The JSON Schema spec allows additionalProperties to be unset. If it's unset, the object has no constraints.

Solution:

If additionalProperties is unset, create pattern allowing for object with any value type by recursively passing {"anyOf": [{"type": "number"}, ...]} to build_regex_from_schema().

To keep the pattern finite, we set the default object nesting depth to 2.

TODO

@lapp0 lapp0 marked this pull request as ready for review May 20, 2024 06:10
@rlouf rlouf merged commit 6f655ca into outlines-dev:main May 22, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"additionalProperties" should not be a required field
3 participants