Deserialize header values before validating#117
Merged
mkon merged 2 commits intoJun 24, 2026
Conversation
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
a0b2e9a to
fef6033
Compare
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.
Header values are always transmitted as strings, but
Validators::Headersvalidated the raw string against the header schema with no deserialization. Any header typed asinteger,number, orbooleancould therefore never validate — e.g. aRateLimit-Limit: 300response header failed against{type: integer}because "300" is a String.Deserialize the value with
OpenapiParameters::Converterbefore validating — the same converterDoc::Parameteralready uses for query parameters — so a header's value is coerced to the type its schema declares (perstyle: simple). Values that can't be parsed are left unchanged and still fail validation.Closes #115