[OpenApi] Ignore unknown HTTP methods#63034
Merged
captainsafia merged 2 commits intodotnet:mainfrom Aug 1, 2025
Merged
Conversation
Exclude unsupported HTTP methods from the OpenAPI document, rather than throwing an exception. Resolves dotnet#60914.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR modifies the OpenAPI document generation to gracefully handle unknown HTTP methods by ignoring them instead of throwing exceptions. The changes allow the system to continue processing supported HTTP methods while silently skipping unsupported ones.
- Modified
GetHttpMethod()to returnHttpMethod?instead of throwing for unknown methods - Updated OpenAPI document service to skip operations with unsupported HTTP methods
- Removed test that verified exception throwing for unknown methods
- Added sample controller methods with unsupported HTTP methods for testing
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| ApiDescriptionExtensions.cs | Changed GetHttpMethod() to return nullable and return null for unknown methods |
| OpenApiDocumentService.cs | Added null checks to skip operations with unsupported HTTP methods |
| ApiDescriptionExtensionsTests.cs | Removed test verifying exception for unknown HTTP methods |
| TestController.cs | Added sample methods with unsupported HTTP methods for testing |
Comments suppressed due to low confidence (1)
src/OpenApi/src/Services/OpenApiDocumentService.cs:260
- [nitpick] Remove the unnecessary blank line. According to the coding guidelines, ensure proper formatting by avoiding extra blank lines.
return paths;
martincostello
commented
Aug 1, 2025
Support generating OpenAPI documentation for HTTP QUERY endpoints. Contributes to dotnet#61089.
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.
Ignore unknown HTTP methods
Description
Exclude unsupported HTTP methods from the OpenAPI document, rather than throwing an exception.
Fixes #60914.