Skip to content

feat: a request sends Accept, the media types its responses declare - #86

Merged
MarkRosemaker merged 3 commits into
mainfrom
feat/accept-header
Nov 25, 2026
Merged

MarkRosemaker merged 3 commits into
mainfrom
feat/accept-header

Conversation

@MarkRosemaker

@MarkRosemaker MarkRosemaker commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Each request now says what it accepts: Accept lists the media types its operation's responses declare, each once, in their order. It's application/json for most, or application/json, application/problem+json where an error response declares its own. Where no response has a body, nothing is sent.

This came from go-api-libs/ibkr. Its newest recording was made by a tool that sends Accept: application/json, and the generated client sent none, so replay failed. Rather than ignore the header, the client now sends what the spec says it accepts. A recording made with Accept checks it against that.

Changes

  • ir.Operation.Accept() builds the header, and client.gen.go.tmpl sends it beside User-Agent.
  • Golden files: I generated each testdata package to a scratch directory and read the diff before applying it. It holds 27 added Accept lines and nothing else: application/json, plus one text/plain and one application/pdf, as those operations' responses declare.
  • TestOperation_Accept covers what the golden files don't: two media types, a repeated one, and a response without a body.
  • README/features.md describes it.
  • Bumped dependencies: go-api-libs/api and cassette move to their mains, which have fix: replay compares a recorded Accept, and allows one a recording lacks go-api-libs/api#11 and feat: OptionalHeaders matches a header recordings may lack cassette#7. Their Replay compares a recorded Accept and allows one a recording lacks, so the generated packages' tests replay their recordings, made without Accept.

make ready passes.

🤖 Generated with Claude Code

https://claude.ai/code/session_019QCb1AfnATvpBQCH3PrX7Y

Each request now says what it accepts: the media types of its operation's
responses, each once, in their order, such as application/json, or nothing
where no response has a body. A recording made with Accept matches it, and
go-api-libs/api's replay allows it where a recording made before lacks it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019QCb1AfnATvpBQCH3PrX7Y
go-api-libs/api#11 replays an Accept a recording lacks, through
MarkRosemaker/cassette#7's OptionalHeaders: the generated packages' tests
replay their recordings, made without Accept, with it. Until both merge, they
are pinned to their commits. README.md follows README/features.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019QCb1AfnATvpBQCH3PrX7Y
@MarkRosemaker
MarkRosemaker merged commit c2b1fbe into main Nov 25, 2026
1 check passed
@MarkRosemaker
MarkRosemaker deleted the feat/accept-header branch November 25, 2026 18:25
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