Skip to content

feat: OptionalHeaders matches a header recordings may lack - #7

Merged
MarkRosemaker merged 1 commit into
mainfrom
feat/optional-headers
Nov 25, 2026
Merged

MarkRosemaker merged 1 commit into
mainfrom
feat/optional-headers

Conversation

@MarkRosemaker

Copy link
Copy Markdown
Owner

go-api-libs' generated clients are to send Accept with the media types each operation's responses declare. Recordings made before don't have it, and stay as recorded. With CompareHeaders, a request that sends Accept would no longer match them.

OptionalHeaders(names...) is a new MatchOption, used beside CompareHeaders. A header it names:

  • is compared exactly where the recording has it;
  • is allowed where the recording lacks it.

OptionalAuthorization already treats credentials this way.

Test: a TestReplay case with /a recorded with Accept: application/json and /b recorded without. /a doesn't match text/html or a missing Accept, and does match application/json. /b matches a request that sends Accept.

make ready passes.

Next: go-api-libs/api's Replay uses OptionalHeaders("Accept") (go-api-libs/api#11), and openapi-codegen's clients send Accept.


Generated by Claude Code

A client that begins to send a header, as go-api-libs' clients are to send
Accept, would no longer match the recordings made before. OptionalHeaders
names headers compared where a recording has them and allowed where it does
not, as OptionalAuthorization does for credentials.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019QCb1AfnATvpBQCH3PrX7Y
@MarkRosemaker
MarkRosemaker merged commit 407fe91 into main Nov 25, 2026
1 check passed
MarkRosemaker pushed a commit to go-api-libs/api that referenced this pull request Nov 25, 2026
MarkRosemaker/cassette#7 adds the OptionalHeaders Replay now uses; until it
merges, cassette is pinned to its commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019QCb1AfnATvpBQCH3PrX7Y
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.

2 participants