Repository navigation
openapi3: resolve refs under a header's content - #1424
Merged
Merged
Conversation
resolveHeaderRef resolved a header's schema but not its content, unlike resolveParameterRef. A $ref in a header's content schema stayed unresolved, so Validate rejected a valid document. A null sub-schema there was never rejected by the loader and made Validate panic with a nil dereference.
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.
resolveHeaderRefresolves a header'sschemabut never looks at itscontent, whileresolveParameterRefwalks both. So whatever sits under a header'scontentstays as it was decoded.A
$refthere is never followed, and a valid document failsValidate:A null sub-schema there (a property with no value, for instance) also gets through. Anywhere else the loader refuses it with
invalid schema: value MUST be an object, but under a header'scontentit stays a nil*SchemaRef, andValidatepanics on it with a nil pointer dereference in(*SchemaRef).validateExtras. I found this one by fuzzingLoadFromDatafollowed byValidate.This walks
contentinresolveHeaderRefwithresolveMediaTypeRefs, the same loopresolveParameterRefalready has.Added
TestLoaderResolvesHeaderContentfor the$refandTestLoaderRejectsNullSchemaInHeaderContentfor the null. Both fail on master.go test ./...,go vet,go generate,maps.shanddocs.share clean.Prepared with Claude Code.