Repository navigation
Conversation
p1c2u
force-pushed
the
feature/oas30-openapi-metaschema
branch
from
November 9, 2026 21:09
93b17bb to
c876e9e
Compare
p1c2u
force-pushed
the
feature/oas30-openapi-metaschema
branch
2 times, most recently
from
November 9, 2026 21:20
62967c7 to
60b074f
Compare
OpenAPI 3.0 schemas were checked against the JSON Schema Draft 4 metaschema, which accepts keywords OpenAPI 3.0 does not support (type arrays, definitions, id, $schema, patternProperties, const, unknown keywords, ...). Vendor the official OAS 3.0 schema (2024-10-18) unmodified and check OAS 3.0 schemas against its Schema, Reference, Discriminator, XML and ExternalDocumentation definitions. Schema or Reference is chosen by the presence of $ref instead of the official oneOf, so errors point at the offending keyword and keys next to $ref are ignored as the specification requires. Apply the check to OAS30Validator and the Strict, Read and Write variants; the variants previously used jsonschema's default Draft 4 check. This is a breaking change: schemas using unsupported keywords, and roots carrying non-Schema Object keys such as components or a whole OpenAPI document, now raise SchemaError. Referenced schemas can be provided via registry, or the check skipped with check_schema=False.
p1c2u
force-pushed
the
feature/oas30-openapi-metaschema
branch
from
November 9, 2026 21:22
60b074f to
bc567a2
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.
Problem
OpenAPI 3.0 schemas are checked against the JSON Schema Draft 4 metaschema. The OAS 3.0 Schema Object is a restricted subset of Wright Draft 00, and JSON Schema keywords it does not list are unsupported (OAS 3.0.3). Draft 4 still accepts
typearrays,definitions,id,$schema,patternProperties,const,itemsarrays and unknown keywords, so invalid 3.0 schemas passcheck_schema.Change
schemas/oas3.0/schema/. The specifications registry picks it up automatically, and it ships in the wheel.check_schemafor OAS 3.0 uses the officialSchema,Reference,Discriminator,XMLandExternalDocumentationdefinitions. This applies toOAS30Validatorand the Strict, Read and Write variants; the variants previously fell back to jsonschema's default Draft 4 check.oneOf: [Schema, Reference]alternatives are rewritten at import time to choose by the presence of$ref, as the specification does. Errors therefore name the offending keyword (['string', 'null'] is not of type 'string','definitions' does not match any of the regexes: '^x-') rather than a generic oneOf failure. Keys next to$refare ignored.META_SCHEMAand instance validation are unchanged.Breaking change
SchemaError.components, or a whole OpenAPI document passed tovalidate().To migrate, provide referenced schemas via
registry=..., validate fragments through a validator built from the full document, or skip the check withcheck_schema=False. This needs a minor version bump (0.10).Not covered, to stay faithful to the official schema: "
itemsMUST be present iftypeisarray" is not enforced.Overlaps with #306, which also changes OAS 3.0 schema checking; whichever merges second will need a rebase.
Checks
tests/unit/test_oas30_schema_object_metaschema.py)_regex.pyerrors that already exist on master-n -Wbuild all clean