Support contentSchema for OpenAPI 3.1 schemas (parse + ContentSchemaIn30 rule) - #207
Open
takayamaki wants to merge 4 commits into
Open
Support contentSchema for OpenAPI 3.1 schemas (parse + ContentSchemaIn30 rule)#207takayamaki wants to merge 4 commits into
takayamaki wants to merge 4 commits into
Conversation
`contentSchema` on a 3.0 document warns and raises (JSON Schema 2020-12 annotation with no 3.0 equivalent); the same keyword on a 3.1 document stays clean.
takayamaki
marked this pull request as ready for review
September 12, 2026 01:17
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.
Continuing the OpenAPI 3.1 work from #152.
OpenAPI 3.1 adopts JSON Schema 2020-12, which brings the
contentSchemaannotation.It attaches a schema to the decoded payload of a string described by
contentMediaType/contentEncoding.3.0 has no keyword for this.
This PR adds parse support and version-mismatch detection.
It completes the trio started in #204 (
contentMediaType) and continued withcontentEncoding.Parse layer
contentSchemais parsed as a nestedSchema(orReference) and exposed ascontent_schema,following the existing snake_case naming for object attributes (
all_of,additional_properties,prefix_items):Following the permissive-parse strategy agreed in #152,
the parse layer accepts
contentSchemaregardless of the declared OpenAPI version.contentSchemais an annotation: it describes the decoded payload rather than constraining the string itself,so there is no runtime validation to add here.
Validating the decoded payload would first require decoding it per
contentEncoding,which is out of scope for this series.
SpecValidator rule
ContentSchemaIn30reports a violation for each schema in a 3.0 document that usescontentSchema:Detection inspects
raw_schemakey presence,so it fires whatever the nested schema contains.