Skip to content

Deserialize header values before validating#117

Merged
mkon merged 2 commits into
mkon:mainfrom
samanthawritescode:fix/deserialize-header-values
Jun 24, 2026
Merged

Deserialize header values before validating#117
mkon merged 2 commits into
mkon:mainfrom
samanthawritescode:fix/deserialize-header-values

Conversation

@samanthawritescode

Copy link
Copy Markdown
Contributor

Header values are always transmitted as strings, but Validators::Headers validated the raw string against the header schema with no deserialization. Any header typed as integer, number, or boolean could therefore never validate — e.g. a RateLimit-Limit: 300 response header failed against {type: integer} because "300" is a String.

Deserialize the value with OpenapiParameters::Converter before validating — the same converter Doc::Parameter already uses for query parameters — so a header's value is coerced to the type its schema declares (per style: simple). Values that can't be parsed are left unchanged and still fail validation.

Closes #115

samanthawritescode and others added 2 commits June 16, 2026 13:16
Header values are always transmitted as strings, but `Validators::Headers`
validated the raw string against the header schema with no deserialization.
Any header typed as `integer`, `number`, or `boolean` could therefore never
validate — e.g. a `RateLimit-Limit: 300` response header failed against
`{type: integer}` because "300" is a String.

Deserialize the value with `OpenapiParameters::Converter` before validating —
the same converter `Doc::Parameter` already uses for query parameters — so a
header's value is coerced to the type its schema declares (per `style: simple`).
Values that can't be parsed are left unchanged and still fail validation.

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

# Conflicts:
#	spec/openapi_contracts/validators/headers_spec.rb
@mkon mkon force-pushed the fix/deserialize-header-values branch from a0b2e9a to fef6033 Compare June 24, 2026 11:39

@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.

Nice 👍

@mkon mkon merged commit 9f40b76 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.

Non-string header schemas always fail because the raw header string isn't coerced per OpenAPI style: simple

2 participants