Skip to content

fix(serialization): references inlining - #3124

Merged
Vincent Biret (baywet) merged 2 commits into
mainfrom
fix/circular-schema-serialization
Oct 19, 2026
Merged

Vincent Biret (baywet) merged 2 commits into
mainfrom
fix/circular-schema-serialization

Conversation

@baywet

Copy link
Copy Markdown
Member
  • fix(serialization): potential infinite loop when inlining references
  • fix(serialization): additional recursive paths

Copilot AI balanced review requested due to automatic review settings October 19, 2026 13:52
@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: C#

C# / code-coverage/dotnet

main be0f4bd fix/circular-schema-... aaee6f9 +/-
93% 93% 0%
View coverage of the 10 most impacted files.
File main be0f4bd fix/circular-schema-... aaee6f9 +/-
/home/runner/wo...penApiHeader.cs 95% 95% 0%
/home/runner/wo...ApiParameter.cs 95% 95% 0%
/home/runner/wo...erenceHolder.cs 95% 95% 0%
/home/runner/wo...emaReference.cs 98% 98% 0%
/home/runner/wo...penApiSchema.cs 99% 99% 0%
/home/runner/wo...LoopDetector.cs 56% 56% 0%
/home/runner/wo...piWriterBase.cs 71% 73% +2%
/home/runner/wo...ypeReference.cs 79% 81% +2%
/home/runner/wo...odyReference.cs 48% 57% +9%
/home/runner/wo...erExtensions.cs 67% 83% +16%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

@baywet
Vincent Biret (baywet) marked this pull request as ready for review October 19, 2026 13:54
@baywet
Vincent Biret (baywet) requested a review from a team as a code owner October 19, 2026 13:54
@baywet
Vincent Biret (baywet) enabled auto-merge (squash) October 19, 2026 13:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants