Skip to content

fix: support reinitializing OpenApiOperation.Tags to null and custom comparers - #3116

Merged
Vincent Biret (baywet) merged 2 commits into
microsoft:mainfrom
austinaviv:fix/operation-tags-null-and-custom-comparer
Oct 21, 2026
Merged

Vincent Biret (baywet) merged 2 commits into
microsoft:mainfrom
austinaviv:fix/operation-tags-null-and-custom-comparer

Conversation

@austinaviv

Copy link
Copy Markdown
Contributor

Description

Aligns OpenApiOperation.Tags setter and copy constructor with OpenApiDocument.Tags so that assigning
ull resets the tags property, and custom equality comparers or sorted sets are retained instead of being forced into OpenApiTagComparer.Instance.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Other (please describe):

Related Issue(s)

Fixes #3115

Changes Made

  • Updated OpenApiOperation.Tags setter to assign _tags = null; when incoming value is null.
  • Added pattern match in OpenApiOperation.Tags setter to preserve custom comparers, SortedSet, and ImmutableSortedSet (matching OpenApiDocument.Tags).
  • Updated OpenApiOperation(OpenApiOperation operation) copy constructor to preserve custom comparers and sorted sets.
  • Added unit tests covering reinitializing tags to null, preserving custom tag comparers, and sorted set handling.

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • All existing tests pass

Checklist

  • My code follows the code style of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Versions applicability

  • My change applies to the version 1.X of the library, if so PR link:
  • My change applies to the version 2.X of the library, if so PR link:
  • My change applies to the version 3.X of the library, if so PR link:
  • I have evaluated the applicability of my change against the other versions above.

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.

🟡 Changes recommended

Immutable-set behavior lacks coverage, and the sorted-set test does not verify comparer preservation.

2 open findings
What changed in this PR

Fixes operation tag resetting and preserves custom set semantics.

Changes:

  • Allows resetting OpenApiOperation.Tags to null.
  • Preserves custom comparers, sorted sets, and immutable sorted sets.
  • Adds regression tests for most updated behaviors.
File Description
src/​Microsoft.OpenApi/​Models/​OpenApiOperation.cs Updates tag assignment and copying behavior.
test/​Microsoft.OpenApi.Tests/​Models/​OpenApiOperationTests.cs Adds tag setter and copy-constructor tests.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Microsoft.OpenApi/Models/OpenApiOperation.cs Outdated
Comment thread test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs Outdated
Comment thread src/Microsoft.OpenApi/Models/OpenApiOperation.cs Fixed
Comment thread src/Microsoft.OpenApi/Models/OpenApiOperation.cs Fixed
Copilot AI balanced review requested due to automatic review settings October 13, 2026 13:29

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.

🔵 Needs a closer look

The new immutable sorted-set assignment and copy paths lack test coverage.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 21, 2026 03:02

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

Static review found no blocking issues, and regression tests cover the intended behavior; tests were not executed.

1 open issue

Review effort: Balanced

…n copy constructor

Align the OpenApiOperation copy constructor with OpenApiOperation.Tags setter to preserve custom equality comparers, sorted sets, and immutable sorted sets, and add corresponding copy constructor unit tests.
Copilot AI balanced review requested due to automatic review settings October 21, 2026 03:19
@austinaviv
Austin Aviv (austinaviv) force-pushed the fix/operation-tags-null-and-custom-comparer branch from 4a8e078 to a8ee1de Compare October 21, 2026 03:19

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 copy-constructor changes have regression coverage and no unresolved findings.

1 open issue

Review effort: Balanced

@baywet Vincent Biret (baywet) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for making the changes!

Comment thread src/Microsoft.OpenApi/Models/OpenApiOperation.cs Outdated
Extract CopyTags static method to deduplicate tag normalization logic between OpenApiOperation.Tags setter and the copy constructor as requested in review.
Copilot AI balanced review requested due to automatic review settings October 21, 2026 17:34

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 changes preserve existing setter behavior and cover the corrected copying behavior with regression tests.

1 open issue

Review effort: Balanced

@baywet Vincent Biret (baywet) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the contribution!

@baywet
Vincent Biret (baywet) enabled auto-merge (squash) October 21, 2026 17:39
@baywet
Vincent Biret (baywet) merged commit 4f53ad5 into microsoft:main Oct 21, 2026
9 checks passed
Vincent Biret (baywet) added a commit that referenced this pull request Oct 21, 2026
…comparers (#3116) (#3142)

* fix: preserve custom tag comparers and sorted sets in OpenApiOperation copy constructor

Align the OpenApiOperation copy constructor with OpenApiOperation.Tags setter to preserve custom equality comparers, sorted sets, and immutable sorted sets, and add corresponding copy constructor unit tests.

* refactor: deduplicate tag normalization logic into static helper

Extract CopyTags static method to deduplicate tag normalization logic between OpenApiOperation.Tags setter and the copy constructor as requested in review.

Co-authored-by: Austin Aviv <abhikr6714@gmail.com>
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.

OpenApiOperation.Tags ignores null assignment and discards custom comparers

4 participants