microsoft / microsoft/typespec
[Bug]: SSEStream response examples are not emitted on OpenAPI 3.2.0
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
### Describe the bug
I have an operation that returns `SSEStream` and I attached a response example with `@@opExample`.
When I emit with `@typespec/openapi3` targeting **`OpenAPI 3.2.0`**, the example is missing from the output: the `text/event-stream` response has `itemSchema` but no `examples`.
There's no error or warning, so the example just silently disappears.
The example itself is valid. If I switch the emitter to **`OpenAPI 3.0.0`**, the same example shows up fine (under `examples`, next to `schema: { type: string }`, with the expected `streams-not-supported` warning). So it only gets dropped on the 3.2.0 stream output.
Versions:
- `@typespec/compiler`: 1.13.0
- `@typespec/http`: 1.13.0
- `@typespec/openapi3`: 1.13.0
- `@typespec/sse`: 0.83.0
- `@typespec/events`: 0.83.0
- `@typespec/streams`: 0.83.0
### Reproduction
https://typespec.io/playground/?tspconfig=ZW1pdDoKICAtICJAdHlwZXNwZWMvb3BlbmFwaTMiCm9wdGlvbnPEItQgxBggIMcPLXZlcnPILsQBLSAiMy4yLjAi&c=aW1wb3J0ICJAdHlwZXNwZWMvaHR0cCI7CtIZc3Nl1RhldmVudHMiOwoKdXNpbmcgSHR0cDvHDFR5cGVTcGVjLlNTRdEURcU5OwoKQHNlcnZpY2UoI3sgdGl0bGU6ICJTU0UgZXhhbXBsZSBkcm9wcGVkIiB9KQpuYW1lc3BhY2UgUmVwcm87Cgptb2RlbCBNZXNzYWdlIHsKICDkAJs6ICJtxhMiO8QTZXh0OiBzdHJpbmc7Cn0KCkDmALcKdW5pb24g5gCLxT3HSSzFJXJvdXRlKCIvc3RyZWFtIikKQGdldApvcMRKZWFtKCk6IFNTRVPFDTzGRT7kANFAb3BF5gC9KMYqLAogICPEXyAgcmV0dXJu5AEGOsgTICBjb250ZW50xhYi5ACu5gFYLcd6xEDEAWJvZHk6ICJkYXRhOiB7XCLkAOtcIjpc6ADtXCIsXMU%2FxRVoZWxsb1wifVxuXG7HQ33EB8UF6wFt5wCs5wDWIiB9Cik7&vs=%7B%7D
### Checklist
- [x] Follow our [Code of Conduct](https://github.com/microsoft/typespec/blob/main/CODE_OF_CONDUCT.md)
- [x] Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- [x] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/Microsoft/typespec/discussions).
- [x] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
Contributor guide
Research direction
Start with the linked TypeSpec playground reproduction and the @typespec/openapi3 emitter, comparing output for OpenAPI 3.2.0 and 3.0.0. Trace SSEStream response generation and how the @@opExample value is handled. Done means the 3.2.0 text/event-stream response includes the example without losing existing stream behavior.
Written by the indexing model from the issue text.
Assessment
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100