Skip to content

Add SSE tests for model shared between streaming and non-streaming responses - #5116

Merged
iscai-msft merged 2 commits into
Azure:mainfrom
iscai-msft:iscai-msft-sse-dual-model-usage
Aug 3, 2026
Merged

Add SSE tests for model shared between streaming and non-streaming responses#5116
iscai-msft merged 2 commits into
Azure:mainfrom
iscai-msft:iscai-msft-sse-dual-model-usage

Conversation

@iscai-msft

Copy link
Copy Markdown
Member

Summary

Adds test coverage for the scenario where a model is used both as a regular HTTP response body and as an SSE event payload — mirroring the Azure Search pattern where KnowledgeBaseRetrievalResponse is used in both:

  • The non-streaming POST /retrieve → 200 response body
  • The response.completed terminal SSE event in POST /retrieveStreamSSEStream<KnowledgeBaseRetrievalStreamEvents>

What's tested

Two new test cases in test/methods/sse.test.ts under "sse model shared with non-streaming response (search-like scenario)":

  1. Terminal SSE event + regular response: A model used as both a 200 response body and a @terminalEvent SSE event correctly gets Output | Json usage from both paths, with proper serialization options.

  2. Non-terminal SSE event + regular response: A model used as both a regular GET response and a named SSE event (non-terminal) also gets correct combined usage.

Both tests verify:

  • Usage flags (Output | Json) are correctly propagated from both the regular response and SSE event paths
  • serializationOptions.json is set on all models
  • SSE metadata (eventType, isTerminalEvent, type, contentType) is correct
  • Request models shared across both operations get Input | Json

Context

See Azure/azure-rest-api-specs#44399 for the Search spec that motivated this test coverage.

…sponses

Add test coverage for the scenario where a model is used both as a regular
HTTP response body and as an SSE event payload (e.g. Search's
KnowledgeBaseRetrievalResponse used in both /retrieve 200 and as the
response.completed terminal SSE event in /retrieveStream).

Verifies that usage flags (Output | Json) and serialization options are
correctly propagated from both code paths.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1d859399-8e9f-4ed4-b596-37fa32575c31
@microsoft-github-policy-service microsoft-github-policy-service Bot added the lib:tcgc Issues for @azure-tools/typespec-client-generator-core library label Jul 30, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 30, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@azure-tools/typespec-client-generator-core@5116

commit: 4424dcb

@github-actions

Copy link
Copy Markdown
Contributor

No changes needing a change description found.

@iscai-msft
iscai-msft enabled auto-merge July 30, 2026 15:50
@azure-sdk-automation

Copy link
Copy Markdown
Contributor

You can try these changes here

🛝 Playground 🌐 Website

@iscai-msft
iscai-msft added this pull request to the merge queue Aug 3, 2026
Merged via the queue into Azure:main with commit 51c20be Aug 3, 2026
32 checks passed
@iscai-msft
iscai-msft deleted the iscai-msft-sse-dual-model-usage branch August 3, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants