-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Update Microsoft.OpenApi to 3.0.0 #64368
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
base: main
Are you sure you want to change the base?
Conversation
Update to `[email protected]` to add basic support for OpenAPI 3.2 and fix compilation errors. Relates to dotnet#64317.
|
Thanks for your PR, @@martincostello. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
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.
Pull Request Overview
This PR updates the Microsoft.OpenApi package from version 2.0.0 to 3.0.0 to add basic support for OpenAPI 3.2 and resolve runtime errors when using the updated library in ASP.NET Core applications.
- Updated Microsoft.OpenApi and Microsoft.OpenApi.YamlReader package versions to 3.0.0
- Changed dictionary types from
Dictionary<string, OpenApiMediaType>toDictionary<string, IOpenApiMediaType>to match the new API - Added defensive type checking when accessing media type properties
- Added OpenAPI 3.2 spec version support and corresponding test snapshots
Reviewed Changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| eng/Versions.props | Updated Microsoft.OpenApi and Microsoft.OpenApi.YamlReader from 2.0.0 to 3.0.0 |
| src/OpenApi/src/Services/OpenApiDocumentService.cs | Changed Content dictionary type from OpenApiMediaType to IOpenApiMediaType |
| src/OpenApi/src/Services/OpenApiGenerator.cs | Changed Content dictionary type from OpenApiMediaType to IOpenApiMediaType |
| src/OpenApi/gen/XmlCommentGenerator.Emitter.cs | Added type checking when setting Example property on media types |
| src/OpenApi/test/.../CustomSchemaTransformerTests.cs | Updated test code to use IOpenApiMediaType interface |
| src/OpenApi/test/.../OpenApiDocumentIntegrationTests.cs | Added OpenApi3_2 spec version to test data |
| src/OpenApi/test/.../OpenApiEndpointRouteBuilderExtensionsTests.cs | Updated OpenAPI version string from 3.1.1 to 3.1.2 in assertions |
| src/OpenApi/test/.../snapshots/OpenApi3_1/*.verified.txt | Updated OpenAPI version from 3.1.1 to 3.1.2 in snapshot files |
| src/OpenApi/test/.../snapshots/OpenApi3_2/*.verified.txt | Added new snapshot files for OpenAPI 3.2.0 spec version |
| src/OpenApi/test/.../snapshots/*#OpenApiXmlCommentSupport.generated.verified.cs | Added type checking when setting Example property in generated code |
| src/OpenApi/test/.../OpenApiDocumentLocalizationTests.VerifyOpenApiDocumentIsInvariant.verified.txt | Updated OpenAPI version from 3.1.1 to 3.1.2 |
When looking through the OpenAPI 3.1 to 3.2 steps https://learn.openapis.org/upgrading/v3.1-to-v3.2#migration-checklist and going through the spec, it doesn't look like there are any real breaking changes. So it really looks like a real minor release 😎. |
Update Microsoft.OpenApi to 3.0.0
Update Microsoft.OpenApi to 3.0.0 for basic OpenAPI 3.2 support.
Description
Update to
[email protected]to add basic support for OpenAPI 3.2 and fix compilation errors when trying to use v3 in an ASP.NET Core application.I'm not sure what exact other changes may be required for full OpenAPI 3.2 compatibility at this stage, but this at least resolves the runtime errors when using Microsoft.OpenApi 3.0.0.
One change that needs some thought is for example that HTTP QUERY is now supported in OpenAPI 3.2:
aspnetcore/src/OpenApi/src/Extensions/ApiDescriptionExtensions.cs
Lines 20 to 33 in 4abe082
It's trivial enough to extend this method to handle QUERY, but then how do we skip it here when the document is going to be serialized in a version that's too low to allow it?
aspnetcore/src/OpenApi/src/Services/OpenApiDocumentService.cs
Lines 289 to 293 in 73d4e56
It also appears that both swagger-ui and redoc don't yet support OpenAPI 3.2:
Contributes to #64317.