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

[Feature] JSON generation should allow false subschemas to blacklist keys #1018

Open
hudson-ai opened this issue Sep 10, 2024 · 1 comment
Open

Comments

@hudson-ai
Copy link
Collaborator

hudson-ai commented Sep 10, 2024

E.g. the following schema should allow the generation of any object that does not contain the key "name":

{
 "type": "object",
 "properties": {
   "name": false
 },
 "required": []
}
@hudson-ai hudson-ai changed the title JSON generation should allow false subschemas to blacklist keys [Feature] JSON generation should allow false subschemas to blacklist keys Sep 10, 2024
@hudson-ai
Copy link
Collaborator Author

Note that

{
 "type": "object",
 "properties": {
   "name": false
 },
 "required": ["name"]
 }

should still raise an exception because there are no valid instances of this schema

hudson-ai added a commit to hudson-ai/guidance that referenced this issue Sep 10, 2024
hudson-ai added a commit that referenced this issue Sep 10, 2024
We were previously supporting `True`/`False` schemas only when nested in
certain places like `items` and `additionalProperties`. This expands our
coverage to handle top-level boolean schemas as well.

Note that we will now raise a `ValueError` for `False` schemas, simply
because there is nothing we can generate in this case.
May need to revisit this (see #1018)
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

No branches or pull requests

1 participant