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

@baywet
Vincent Biret (baywet) merged commit c6ef130 into main Oct 19, 2026
20 checks passed
@baywet
Vincent Biret (baywet) deleted the fix/circular-schema-serialization branch October 19, 2026 16:53
Penguin Converters (PenguinConverters) pushed a commit to PenguinConverters/Syntra that referenced this pull request Nov 24, 2026
Updated [Microsoft.OpenApi](https://github.com/Microsoft/OpenAPI.NET)
from 3.10.2 to 3.11.0.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.OpenApi's
releases](https://github.com/Microsoft/OpenAPI.NET/releases)._

## 3.11.0

##
[3.11.0](microsoft/OpenAPI.NET@v3.10.2...v3.11.0)
(2026-10-19)


### Features

* **document:** add GetOperationById to search operations across path…
([#​3025](microsoft/OpenAPI.NET#3025))
([1dae1ff](microsoft/OpenAPI.NET@1dae1ff))


### Bug Fixes

* components-key validation timeouts under load
([#​3108](microsoft/OpenAPI.NET#3108))
([01d4729](microsoft/OpenAPI.NET@01d4729))
* **openapi:** omit null response descriptions
([afd4967](microsoft/OpenAPI.NET@afd4967))
* **serialization:** potential infinite loop when inlining references
([c6ef130](microsoft/OpenAPI.NET@c6ef130))
* **serialization:** references inlining
([#​3124](microsoft/OpenAPI.NET#3124))
([c6ef130](microsoft/OpenAPI.NET@c6ef130))

Commits viewable in [compare
view](microsoft/OpenAPI.NET@v3.10.2...v3.11.0).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=Microsoft.OpenApi&package-manager=nuget&previous-version=3.10.2&new-version=3.11.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This was referenced Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants