Repository navigation
fix(serialization): references inlining - #3124
Merged
Merged
Conversation
Vincent Biret (baywet)
commented
Oct 19, 2026
Member
- fix(serialization): potential infinite loop when inlining references
- fix(serialization): additional recursive paths
Code coverage overviewLanguages: C# C# / code-coverage/dotnet
View coverage of the 10 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. |
Vincent Biret (baywet)
marked this pull request as ready for review
October 19, 2026 13:54
Vincent Biret (baywet)
enabled auto-merge (squash)
October 19, 2026 13:55
There was a problem hiding this comment.
🟢 Approval recommended
The focused safeguards and regression coverage leave no identified blocking issues; tests were not executed.
No open issues 🎉
1 file not reviewed
src/Microsoft.OpenApi/Properties/SRResource.Designer.cs: Generated file
What changed in this PR
Bounds reference inlining during OpenAPI serialization to prevent runaway expansion.
Changes:
- Adds a configurable per-writer expansion limit, defaulting to 10,000.
- Applies counting across reference serialization and conversion paths, with reliable loop-detector cleanup.
- Adds regression tests for limits, writer reuse, and supported output versions.
| File | Description |
|---|---|
| test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterInlineReferenceTests.cs | Tests expansion limits and affected serialization paths. |
| src/Microsoft.OpenApi/Writers/OpenApiWriterSettings.cs | Exposes the configurable expansion limit. |
| src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs | Tracks expansions and enforces the limit. |
| src/Microsoft.OpenApi/PublicAPI.Unshipped.txt | Records the new public setting. |
| src/Microsoft.OpenApi/Properties/SRResource.resx | Adds the limit-exceeded message. |
| src/Microsoft.OpenApi/Properties/SRResource.Designer.cs | Exposes the message resource. |
| src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs | Ensures loop cleanup after exceptions. |
| src/Microsoft.OpenApi/Models/References/OpenApiRequestBodyReference.cs | Counts request-body conversion expansions. |
| src/Microsoft.OpenApi/Models/References/OpenApiMediaTypeReference.cs | Counts media-type expansions. |
| src/Microsoft.OpenApi/Models/References/BaseOpenApiReferenceHolder.cs | Counts shared reference serialization expansions. |
| src/Microsoft.OpenApi/Models/OpenApiParameter.cs | Counts schema expansion for V2 parameters. |
| src/Microsoft.OpenApi/Models/OpenApiHeader.cs | Counts schema expansion for V2 headers. |
| src/Microsoft.OpenApi/Extensions/OpenAPIWriterExtensions.cs | Routes counting to supported writers. |
Review effort: Balanced
|
Gavin Barron (gavinbarron)
approved these changes
Oct 19, 2026
Adrian (adrian05-ms)
approved these changes
Oct 19, 2026
This was referenced Oct 19, 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.


