feat(api): return the target session from POST /mocks#335
Merged
Conversation
The response now includes the session (id + name) the mocks were registered in, so callers — shell scripts especially — can chain GET /mocks?session=<id> without a separate GET /sessions lookup. Additive: the "message" field is unchanged. Session names are not a reliable key (they need not be unique); the opaque id is. Relates to #312. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Relates to #312.
What
POST /mocksnow returns the target session (id+name+date) alongside the existing message:{ "message": "Mocks registered successfully", "session": { "id": "W0dArqgEPE4m", "name": "my-suite", "date": "..." } }Why
Registering mocks (optionally creating a session via
?newSession=<name>) previously returned only a message, with no session id — so a caller, especially a shell script, had no handle to then fetch the mocks it just registered. It had toGET /sessionsand guess by name, which isn't reliable (session names need not be unique; the opaque id is the key — seePRINCIPLES.md§3.6).Now the flow is a clean chain:
Compatibility
Purely additive — the
messagefield is unchanged, so existing clients are unaffected.Verified
session.id/session.namein the response.POST /mocks?newSession=my-suitereturns the session id, andGET /mocks?session=<id>returns the registered mock.🤖 Generated with Claude Code