-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Update to Microsoft.OpenApi v2.0.0-preview.11 #60761
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR updates the Microsoft.OpenApi dependency to v2.0.0-preview.11 and removes now‑redundant custom implementations. It also removes workarounds for serialization issues and updates reader registration to align with the new API.
- Updates OpenAPI deserialization by replacing comparer logic with native set handling.
- Removes snapshot test scrubbing for date-based examples due to an upstream bug fix.
- Adapts endpoint routing tests to use new reader settings for YAML support.
Reviewed Changes
File | Description |
---|---|
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Build.Tests/GenerateAdditionalXmlFilesForOpenApiTests.cs | Adds a check for Microsoft.AspNetCore.Identity XML generation. |
src/OpenApi/src/Services/OpenApiDocumentService.cs | Removes redundant tag comparer usage and adjusts tag collection types to use sets. |
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/OpenApiDocumentIntegrationTests.cs | Removes date-time scrubbing now that the upstream serialization issue is fixed. |
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Extensions/OpenApiEndpointRouteBuilderExtensionsTests.cs | Updates reader registration from deprecated methods to OpenApiReaderSettings. |
src/OpenApi/src/Services/OpenApiGenerator.cs | Updates tag collection handling by moving from lists to sets for unique tags. |
src/OpenApi/src/Comparers/OpenApiTagComparer.cs | Removes the now‑redundant custom tag comparer. |
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
src/OpenApi/src/Services/OpenApiDocumentService.cs:349
- [nitpick] For clarity and consistency, consider explicitly using the constructor name ('new OpenApiTagReference(controllerName, document)') rather than relying on type inference in the collection initializer.
return new HashSet<OpenApiTagReference> { new(controllerName, document) };
src/OpenApi/src/Services/OpenApiGenerator.cs:364
- [nitpick] Consider explicitly specifying the type when creating a new OpenApiTagReference for consistency and clarity, e.g. 'new OpenApiTagReference(controllerName, document)'.
return new HashSet<OpenApiTagReference>
{
new(controllerName, document)
};
OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yaml, new OpenApiYamlReader()); | ||
var result = await OpenApiDocument.LoadAsync(documentStream, format); | ||
var readerSettings = new OpenApiReaderSettings(); | ||
readerSettings.AddYamlReader(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so much nicer than that static registration.
@@ -42,7 +38,6 @@ public async Task VerifyOpenApiDocument(string documentName, OpenApiSpecVersion | |||
var outputDirectory = Path.Combine(baseSnapshotsDirectory, version.ToString()); | |||
await Verifier.Verify(json) | |||
.UseDirectory(outputDirectory) | |||
.ScrubLinesWithReplace(line => DateTimeRegex().Replace(line, "[datetime]")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this that bug I reported last week?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! It got fixed in preview9 or preview10 I believe.
Condition="'%(ReferencePath.Extension)' == '.dll' AND | ||
Exists('%(ReferencePath.RootDir)%(ReferencePath.Directory)%(ReferencePath.Filename).xml') AND | ||
('%(ReferencePath.ReferenceSourceTarget)' == 'ProjectReference')" | ||
Condition=" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a comment here for what we're doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Funny story I have to revert this because of #60783 but I will be sure to add a comment once I've recolved that issue.
@@ -327,15 +326,15 @@ private async Task<OpenApiOperation> GetOperationAsync( | |||
=> description.ActionDescriptor.AttributeRouteInfo?.Name ?? | |||
description.ActionDescriptor.EndpointMetadata.OfType<IEndpointNameMetadata>().LastOrDefault()?.EndpointName; | |||
|
|||
private static List<OpenApiTagReference> GetTags(ApiDescription description, OpenApiDocument document) | |||
private static ISet<OpenApiTagReference> GetTags(ApiDescription description, OpenApiDocument document) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extreme nit: Generally for private/internal methods we can return the concrete type instead of an interface, this allows for optimizations at the usage site. I know the return values here are just set on an OpenAPI type, but just a general pattern.
This reverts commit 048240f.
Part of #58619.
Update to the latest preview of Microsoft.OpenApi ahead of preview3. Changes consumed:
A change unrelated to the upgrade: