-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
captainsafia
merged 7 commits into
dotnet:main
from
sander1095:GH-59175-openapi-case-insensitive-url
Dec 16, 2024
Merged
Change OpenAPI document name resolution to be case-insensitive #59199
captainsafia
merged 7 commits into
dotnet:main
from
sander1095:GH-59175-openapi-case-insensitive-url
Dec 16, 2024
Conversation
This file contains 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
captainsafia
reviewed
Dec 9, 2024
src/OpenApi/src/Extensions/OpenApiServiceCollectionExtensions.cs
Outdated
Show resolved
Hide resolved
captainsafia
reviewed
Dec 9, 2024
.../Microsoft.AspNetCore.OpenApi.Tests/Extensions/OpenApiEndpointRouteBuilderExtensionsTests.cs
Show resolved
Hide resolved
captainsafia
approved these changes
Dec 16, 2024
4 tasks
captainsafia
pushed a commit
that referenced
this pull request
Feb 11, 2025
* Fix analyser error * Wrote unit test to verify when bug is fixed * Register document names in a case-insensitive manner * Change OpenAPI document name resolution to be case-insensitive * Restore AddOpenApiCore to its own method * Fix typo in extension method
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
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.
Change OpenAPI document name resolution to be case-insensitive
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
'sAddOpenApi()
andMapOpenApi()
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