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

🐛 Fix JSON Schema accepting bools as valid JSON Schemas, e.g. additionalProperties: false #9781

Merged
merged 3 commits into from Jul 2, 2023

Conversation

tiangolo
Copy link
Owner

@tiangolo tiangolo commented Jul 2, 2023

🐛 Fix JSON Schema accepting bools as valid JSON Schemas, e.g. additionalProperties: false

This solves: #9780


A "valid JSON Schema" includes a bool (i.e. true and false).

additionalProperties doesn't have to be a JSON object, it can be false, to mean no additional properties are allowed.

When I upgraded the JSON Schema models to include the new types and fields for the new JSON Schema 2020-12 I removed bool as a valid JSON Schema.

I reviewed all the spec again, this updates all the other fields that would allow bool as a valid value.

@tiangolo tiangolo merged commit 07e1dea into master Jul 2, 2023
14 checks passed
@tiangolo tiangolo deleted the json-schema-bool-valid branch July 2, 2023 15:58
wdh99 pushed a commit to wdh99/fastapi that referenced this pull request Jul 4, 2023
…onalProperties: false` (tiangolo#9781)

* 🐛 Fix JSON Schema accepting bools as valid JSON Schemas, e.g. additionalProperties: false

* ✅ Add test to ensure additionalProperties can be false

* ♻️ Tweak OpenAPI models to support Pydantic v1's JSON Schema for tuples
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.

None yet

1 participant