Skip to content
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

Change OpenAPI document name resolution to be case-insensitive #59199

Merged

Conversation

sander1095
Copy link
Contributor

@sander1095 sander1095 commented Nov 27, 2024

Change OpenAPI document name resolution to be case-insensitive

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Case-sensitive urls are now supported when retrieving OpenAPI documents.

Description

There was a routing issue when using case-sensitive document names in Microsoft.AspNetCore.OpenApi's AddOpenApi() and MapOpenApi() methods. If you registered a document in a case-sensitive manner (MyDocument) and tried to retrieve it at /openapi/mydocument.json, it would result in a 404.

This is odd, as ASP.NET Core's routing has always been case-insensitive by default.

The reason for this bug is that keyed services are used to register relevant services. The key is the document name, and keyed services are case-sensitive.

This PR changes this inconsistent behaviour by allowing case-insensitive document resolution by invariantly lowercasing both the registered document name and the document name that's being retrieved.

Fixes #59175

@sander1095 sander1095 requested review from captainsafia and a team as code owners November 27, 2024 14:57
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels label Nov 27, 2024
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Nov 27, 2024
@martincostello martincostello added feature-openapi area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc labels Nov 27, 2024
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Dec 5, 2024
@mkArtakMSFT mkArtakMSFT removed the area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels label Dec 13, 2024
@captainsafia captainsafia enabled auto-merge (squash) December 16, 2024 22:28
@captainsafia captainsafia merged commit 09d7789 into dotnet:main Dec 16, 2024
27 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-preview1 milestone Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc community-contribution Indicates that the PR has been added by a community member feature-openapi pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OpenAPI document names are case-sensitive in urls
4 participants