Repository navigation
Fix ignored keywords in schemas without type - #223
Merged
Merged
Conversation
takayamaki
marked this pull request as ready for review
October 23, 2026 04:09
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A schema without type skipped every keyword, so properties did not check the value. JSON Schema, which OpenAPI 3.1 follows, applies properties to an object whether or not type is set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
These already pass with the previous change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also pin enum for a string, which already passes with the previous change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…type These already pass with the previous changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It now also picks the type for a schema without type, not only from array-form type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
takayamaki
force-pushed
the
untyped-schema-keywords
branch
from
October 24, 2026 12:15
159195a to
8474b3b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #215 (item 9).
A schema without
typeskipped every keyword.For example, this schema accepted
{ "count": "x" }and{}:In JSON Schema, which OpenAPI 3.1 follows, a keyword applies when the value has the type the keyword is for.
typedoes not need to be set.So
propertiesandrequiredapply to an object, andmaxLengthapplies to a string.Changes
typeis not set, the validator picks the type from the value, and then validates the value in the same way as a schema with that type.It reuses
pick_array_type, renamed topick_type, which already does this for array-formtype.For example,
propertiesdoes not reject a string.Date, is still accepted without checks.I checked the same cases with three well-known JSON Schema validators.
They all give the same results, for both Draft 2020-12 and Draft 4:
ajv 8.20.0, python-jsonschema 4.26.0 and json_schemer 2.5.0.
type: objectwithproperties1propertieswithouttype1propertieswithouttype{ "count": 1 }propertieswithouttype{ "count": "x" }propertieshere is{ count: { type: integer } }.Only the last row differed from the three validators before this change.
I did not check the declared version.
The OpenAPI 3.0 Schema Object also follows JSON Schema here, so the same fix is right for 3.0 documents.
Compatibility
This makes validation stricter.
A value that breaks a keyword in a schema without
typeused to pass, and now fails.I added a note in the CHANGELOG.
I did not add a config option, but I can add one if you prefer.
The committee test suite passes with this branch.
nullfor a schema withouttypeis not changed here.It is still rejected, as described in #215 item 5.