feat: adds support for describing SSE in OpenAPI 3.2.0#67461
Merged
Conversation
1 task
Contributor
There was a problem hiding this comment.
Pull request overview
Adds OpenAPI document generation support for Server-Sent Events (SSE) responses by emitting OpenAPI 3.2-style sequential media type metadata (itemSchema) for text/event-stream, including deriving event enum values from unions and polymorphic discriminator mappings.
Changes:
- Detect
text/event-streamresponses whose response type isSseItem<T>and emit an SSE “item schema” instead of a normal media-type schema. - Populate the SSE item schema with
data,event, andidproperties, and infereventenums from union cases and discriminator mappings when available. - Add tests validating
itemSchemausage andeventenum inference for plain, union, and discriminator-based payload types.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/OpenApi/src/Services/OpenApiDocumentService.cs | Detect SSE responses and generate text/event-stream media types using ItemSchema, including event enum inference from unions/discriminators. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiDocumentService/OpenApiDocumentServiceTests.Responses.cs | Adds coverage for SSE itemSchema output and validates event schema behavior for different payload shapes. |
Youssef1313
reviewed
Jun 29, 2026
Youssef1313
reviewed
Jun 29, 2026
Youssef1313
reviewed
Jun 29, 2026
Youssef1313
reviewed
Jun 29, 2026
Youssef1313
reviewed
Jun 29, 2026
Youssef1313
reviewed
Jun 29, 2026
javiercn
reviewed
Jul 1, 2026
halter73
reviewed
Jul 1, 2026
1 task
Signed-off-by: Vincent Biret <vincentbiret@hotmail.com>
Signed-off-by: Vincent Biret <vincentbiret@hotmail.com>
Signed-off-by: Vincent Biret <vincentbiret@hotmail.com>
Signed-off-by: Vincent Biret <vincentbiret@hotmail.com>
Signed-off-by: Vincent Biret <vincentbiret@hotmail.com>
halter73
reviewed
Jul 2, 2026
Co-authored-by: Stephen Halter <shalter+msft@microsoft.com>
Youssef1313
approved these changes
Jul 7, 2026
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.
fixes #64379
Examples
CC @martincostello