Skip to content

Conversation

martincostello
Copy link
Member

@martincostello martincostello commented Aug 1, 2025

Ignore unknown HTTP methods

  • Ignore unknown HTTP methods from OpenAPI documents.
  • Generate OpenAPI operations for HTTP QUERY.

Description

Exclude unsupported HTTP methods from the OpenAPI document, rather than throwing an exception.

Fixes #60914.

Exclude unsupported HTTP methods from the OpenAPI document, rather than throwing an exception.

Resolves dotnet#60914.
@Copilot Copilot AI review requested due to automatic review settings August 1, 2025 11:41
@martincostello martincostello requested review from captainsafia and a team as code owners August 1, 2025 11:41
@github-actions github-actions bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Aug 1, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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 return HttpMethod? 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;

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Aug 1, 2025
martincostello
martincostello commented