A few edits on your v3.1 PR#15
Merged
reuvenharrison merged 23 commits intooasdiff:feat/openapi-3.1-supportfrom Apr 23, 2026
Merged
A few edits on your v3.1 PR#15reuvenharrison merged 23 commits intooasdiff:feat/openapi-3.1-supportfrom
reuvenharrison merged 23 commits intooasdiff:feat/openapi-3.1-supportfrom
Conversation
43 tasks
f884e17 to
18d29b0
Compare
…penAPI31OrLater and doc.OpenAPIMajorMinor Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
…1OrLater Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
…idationOption) error Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
…TLS for v3.0 Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
Pierre's FIXME on PR getkin#15: the helper previously covered only 8 fields (deprecated, description, title, readOnly, writeOnly, example, externalDocs, default). Extend to every field in the Schema struct so any sibling keyword alongside $ref in an OAS 3.1 document is correctly overlaid onto the resolved $ref target. Section comments dropped: the entire function runs only when the caller has already checked IsOpenAPI31OrLater(), so splitting cases by OAS version inside the switch was misleading. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Split the $ref sibling-fields check out of (*Ref).Validate into a dedicated validateExtras method, generated from refs.tmpl for every Ref type. This lets subsequent patches invoke validateExtras on SchemaRefs referenced from inside a schema tree — i.e. at the sites where Schema.validate recurses into nested SchemaRefs — without duplicating the check logic. Template update + `go generate` regeneration. No behaviour change: Validate still returns the same error for the same inputs; the check is just reachable from additional call sites. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
…ression
TestSchemaRefSiblingKeyword/{3.0 false false} (added by @fenollp in
this PR) exposed that $ref sibling fields (e.g. description,
deprecated) were accepted on nested property schemas in OAS 3.0 when
they should have been rejected. Root cause: SchemaRef.validateExtras
was invoked only from SchemaRef.Validate, but nested schema
validation in Schema.validate recursed directly into
ref.Value.Validate, bypassing the ref-level extras check.
Invoke ref.validateExtras(ctx) at every nested SchemaRef site: items,
properties, additionalProperties, prefixItems, contains,
patternProperties, dependentSchemas, $defs, propertyNames,
unevaluatedItems, unevaluatedProperties, contentSchema, if/then/else.
Drop the t.Skip on TestSchemaRefSiblingKeyword now that all three
subcases pass.
Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
…o $ref
lxkns.yaml is OAS 3.0.2 and uses `description` as a sibling to $ref in
many places, which is invalid in OAS 3.0 ($ref replaces the enclosing
object; siblings are ignored). Previously this was silently accepted
because validateExtras was only invoked on top-level component refs.
Now that nested SchemaRefs are validated too, those siblings surface
as a validation error and mask the example-type mismatch this test
actually targets.
Pass AllowExtraSiblingFields("description") so validation proceeds to
the example-type assertion the test was written for (same pattern
already used in issue513_test.go:264).
Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Per Pierre's PR getkin#15 review: Schema.validate accepted OAS 3.1 / JSON Schema 2020-12 fields (prefixItems, contains, if/then/else, $defs, $schema, patternProperties, unevaluatedItems, etc.) on OAS 3.0 documents. Add a gate at the top of Schema.validate that rejects each 3.1-only field in 3.0 mode via errFieldFor31Plus. The gate honours AllowExtraSiblingFields so 3.0 documents that resolve external JSON Schema refs (draft-04, draft-07) can opt in to letting $id/$schema/etc. through. This matches the existing opt-in mechanism already used by TestExtraSiblingsInRemoteRef. This whole block becomes a no-op once OAS 3.0 gets its own standalone schema validator. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Three tests need adjustment now that OAS 3.1-only schema fields are
rejected under OAS 3.0 validation:
- TestSchemaIfThenElse_Validate and TestSchemaValidate31SubSchemas
exercise 3.1 features (If/Then/Else, PrefixItems) directly via
Schema.Validate without a doc, so the isOpenAPI31OrLater flag is
never set from a doc version. Pass IsOpenAPI31OrLater() explicitly.
- TestIssue495WithDraft04{,Bis} load OAS 3.0 documents that $ref
external JSON Schema draft-04 meta-schemas (which contain $id and
$schema). Add AllowExtraSiblingFields("$id", "$schema") so the
tests assertion about the unresolved inner "#" ref surfaces as
intended, matching the pattern already used in issue513_test.go.
Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
ac00372 to
54e52d7
Compare
092f3e4
into
oasdiff:feat/openapi-3.1-support
5 checks passed
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.
Hello! Thanks for tackling this, especially the schema part!
I think this should move forward as-is however I have a few points:
Regarding v3.1 sibling fields: this was missing tests which I added. One test (for v3.0) is not passing so please take a look. Also please complete the implementation of
applySiblingSchemaFields. I can't merge this with this regression for 3.0.Be more careful when adding new v3.1 capabilities in general: things have to be gated with
IsOpenAPI31OrLater()! So please go over the Schema's Validate func and gate the usage of v3.1 fields.I renamed some things and decoupled the options "isopenapiv3.1" and "usenewschema". Because the first is required when validating oas documents and the later will end up being a noop once I replace v3.0's custom schema validation with the new one.
Oh let's try to not squash the commits please.