Skip to content

Resolve $ref in response header objects#116

Merged
mkon merged 1 commit into
mkon:mainfrom
samanthawritescode:fix/resolve-response-header-refs
Jun 24, 2026
Merged

Resolve $ref in response header objects#116
mkon merged 1 commit into
mkon:mainfrom
samanthawritescode:fix/resolve-response-header-refs

Conversation

@samanthawritescode

Copy link
Copy Markdown
Contributor

Doc::Response#headers mapped the raw header hash straight to Doc::Header, so a header defined as a $ref (e.g. to #/components/headers/*) was never dereferenced. Doc::Header#schema then returned nil, and Validators::Headers raised NoMethodError: undefined method 'empty?' for nil from JSONSchemer.schema(nil) whenever such a header was present on the response being validated.

Build headers via @schema.navigate('headers'), mirroring how WithParameters#parameters already resolves parameters, so inline and referenced headers are followed identically.

Closes #114

`Doc::Response#headers` mapped the raw header hash straight to `Doc::Header`,
so a header defined as a `$ref` (e.g. to `#/components/headers/*`) was never
dereferenced. `Doc::Header#schema` then returned `nil`, and
`Validators::Headers` raised `NoMethodError: undefined method 'empty?' for nil`
from `JSONSchemer.schema(nil)` whenever such a header was present on the
response being validated.

Build headers via `@schema.navigate('headers')`, mirroring how
`WithParameters#parameters` already resolves parameters, so inline and
referenced headers are followed identically.

Co-authored-by: Claude <noreply@anthropic.com>

@mkon mkon left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

@mkon mkon merged commit d18dd76 into mkon:main Jun 24, 2026
82 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validation crashes when response header is defined via $ref

2 participants