Skip to content

feat(api): return the target session from POST /mocks#335

Merged
gwleclerc merged 1 commit into
mainfrom
feat/post-mocks-returns-session
Jul 19, 2026
Merged

feat(api): return the target session from POST /mocks#335
gwleclerc merged 1 commit into
mainfrom
feat/post-mocks-returns-session

Conversation

@gwleclerc

Copy link
Copy Markdown
Collaborator

Relates to #312.

What

POST /mocks now 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 to GET /sessions and guess by name, which isn't reliable (session names need not be unique; the opaque id is the key — see PRINCIPLES.md §3.6).

Now the flow is a clean chain:

sid=$(curl -s -XPOST "$SMOCKER/mocks?newSession=my-suite" --data-binary @mocks.yml | jq -r .session.id)
curl -s "$SMOCKER/mocks?session=$sid"

Compatibility

Purely additive — the message field is unchanged, so existing clients are unaffected.

Verified

  • Unit + golden/schema tests green; a venom assertion covers session.id / session.name in the response.
  • Runtime: POST /mocks?newSession=my-suite returns the session id, and GET /mocks?session=<id> returns the registered mock.

🤖 Generated with Claude Code

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>
@gwleclerc
gwleclerc merged commit c270749 into main Jul 19, 2026
6 checks passed
@gwleclerc
gwleclerc deleted the feat/post-mocks-returns-session branch July 19, 2026 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant