Skip to content

fix: Improve handling of OpenAPI tag references #2325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 15, 2025

Conversation

martincostello
Copy link
Contributor

  • Update OpenApiTagComparer to behave intuitively with OpenApiTagReference instances pointing to tags not defined in an OpenApiDocument.
  • Verify OpenAPI tag references refer to a valid OpenAPI tag in the document on serialization.

Fixes #2319.

Update `OpenApiTagComparer` to behave intuitively with `OpenApiTagReference` instances pointing to tags not defined in an `OpenApiDocument`.

Contributes to microsoft#2319.
Verify OpenAPI tag references refer to a valid OpenAPI tag in the document on serialization.

Resolves microsoft#2319.
@martincostello martincostello requested a review from a team as a code owner April 15, 2025 10:12
Copy link
Member

@baywet baywet left a comment

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 baywet enabled auto-merge (squash) April 15, 2025 12:22
Comment on lines +364 to +370
foreach (var tag in tags)
{
if (tag.Target is null)
{
throw new OpenApiException($"The OpenAPI tag reference '{tag.Reference.Id}' does reference a valid tag.");
}
}

Check notice

Code scanning / CodeQL

Missed opportunity to use Where Note

This foreach loop
implicitly filters its target sequence
- consider filtering the sequence explicitly using '.Where(...)'.
@baywet baywet merged commit bf9954a into microsoft:main Apr 15, 2025
9 checks passed
@martincostello martincostello deleted the gh-2319 branch April 15, 2025 12:25
martincostello added a commit to martincostello/OpenAPI.NET that referenced this pull request Apr 30, 2025
Fix typo in error message introduced by microsoft#2325.
@martincostello martincostello mentioned this pull request Apr 30, 2025
MaggieKimani1 pushed a commit that referenced this pull request Apr 30, 2025
Fix typo in error message introduced by #2325.
martincostello added a commit to domaindrivendev/Swashbuckle.AspNetCore that referenced this pull request May 16, 2025
Fix tests due to error in test setup fixture caused by changes in microsoft/OpenAPI.NET#2325.
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.

Only one tag is returned on operations when OpenApiTagReference is used
3 participants