feat: adds support for additional operations emission in OpenAPI 3.2.0#67007
Open
baywet wants to merge 4 commits into
Open
feat: adds support for additional operations emission in OpenAPI 3.2.0#67007baywet wants to merge 4 commits into
baywet wants to merge 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Extends OpenAPI generation and traversal to support custom HTTP methods (e.g., FOO) in addition to standard spec methods, and updates unit/integration snapshots accordingly.
Changes:
- Allow
ApiDescription.GetHttpMethod()to return customHttpMethodinstances instead ofnullfor unknown methods. - Update
OpenApiDocumentService.ForEachOperationAsyncto iterate over all operations present on a path item (including custom methods). - Add/adjust tests and snapshot baselines to validate custom-method handling in generated documents.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiDocumentService/OpenApiDocumentServiceTests.QueryMethod.cs | Adds tests + a custom HttpMethodAttribute to verify custom methods appear and are visited in traversal. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentLocalizationTests.VerifyOpenApiDocumentIsInvariant.verified.txt | Updates expected snapshot output to include custom method under /unsupported. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApi3_2/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=controllers.verified.txt | Updates OpenAPI 3.2 snapshot to include additionalOperations for custom method. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApi3_1/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=controllers.verified.txt | Updates OpenAPI 3.1 snapshot to include custom method extension output. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApi3_0/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=controllers.verified.txt | Updates OpenAPI 3.0 snapshot to include custom method extension output. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Extensions/ApiDescriptionExtensionsTests.cs | Updates unit tests for custom methods and adds coverage for missing/blank HttpMethod strings. |
| src/OpenApi/src/Services/OpenApiDocumentService.cs | Iterates over all operations in a path item instead of a fixed list of HTTP methods. |
| src/OpenApi/src/Services/OpenApiConstants.cs | Removes pre-allocated HTTP method array no longer used by traversal logic. |
| src/OpenApi/src/Extensions/ApiDescriptionExtensions.cs | Returns a custom HttpMethod for unknown methods; adds null/whitespace guard. |
Comment on lines
+166
to
+172
| if (pathItem.Operations is null) | ||
| { | ||
| var httpMethod = OpenApiConstants.HttpMethods[i]; | ||
| if (pathItem.Operations is null || !pathItem.Operations.TryGetValue(httpMethod, out var operation)) | ||
| { | ||
| continue; | ||
| } | ||
| continue; | ||
| } | ||
|
|
||
| foreach (var operation in pathItem.Operations.Values) | ||
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
follow up to #65714
CC @martincostello