-
Notifications
You must be signed in to change notification settings - Fork 10.4k
[OpenApi] Ignore unknown HTTP methods #63034
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
Exclude unsupported HTTP methods from the OpenAPI document, rather than throwing an exception. Resolves dotnet#60914.
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 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;
Support generating OpenAPI documentation for HTTP QUERY endpoints. Contributes to dotnet#61089.
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.
LGTM!
Ignore unknown HTTP methods
Description
Exclude unsupported HTTP methods from the OpenAPI document, rather than throwing an exception.
Fixes #60914.