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

Support boolean schemas #35

Open
jcklie opened this issue Jun 4, 2024 · 2 comments
Open

Support boolean schemas #35

jcklie opened this issue Jun 4, 2024 · 2 comments

Comments

@jcklie
Copy link

jcklie commented Jun 4, 2024

JSON schema has a niche case where are allowed to just consist of a boolean 1. Therefore, this is a valid schema:

{
    "type": "object",
    "properties": {
        "foo": {
          "type": "array",
    	  "items": true  
        },
        "bar": false
    }
}

I encountered some schemas using this in real life that used this feature and fail parsing with this package. I see two solutions to this problem: extending the union wherever there is a schema used, e.g. turn all Union[Ref, Schema] into Union[Ref, Schema, bool] or make schema itself a union of Schema and Bool and rename the existing schema to something like JsonSchema. I hacked it for myself to use the former solution.

@mike-oakley
Copy link
Owner

Hi @jcklie - thanks for reaching out! Happy to accept a contribution for this, probably the latter solution (make schema itself a union of Schema and Bool and rename the existing schema to something like JsonSchema) would be preferable in my mind to reduce the number of places that need updating?

@rafalkrupinski
Copy link

i would find it confusing, if there were both Schema and JsonSchema types in the project.

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

3 participants