-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix OpenAPI generator crash on routes starting with '~' #64408
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
base: main
Are you sure you want to change the base?
Conversation
|
Greetings human! You've submitted a PR that modifies code that is shared with https://github.com/dotnet/runtime . Please make sure you synchronize this code with the changes in that repo! |
… to use it Co-authored-by: captainsafia <1857993+captainsafia@users.noreply.github.com>
Co-authored-by: captainsafia <1857993+captainsafia@users.noreply.github.com>
| } | ||
|
|
||
| [Fact] | ||
| public async Task GetOpenApiPaths_HandlesRoutesStartingWithTilde() |
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.
@copilot Add a test that validates the behavior of these types of paths from a controller action.
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.
Added test GetOpenApiPaths_HandlesRoutesStartingWithTilde_MvcAction that validates routes starting with ~ from MVC controller actions. The test uses a controller action with [Route("/~health")] attribute and verifies the OpenAPI document is generated correctly. Commit: e48e103
Co-authored-by: captainsafia <1857993+captainsafia@users.noreply.github.com>
Fix OpenAPI generator crash on routes starting with '~'
Store RoutePattern on ApiDescription to avoid reparsing
Description
MapRelativePathToItemPathwas reparsingRelativePathwithRoutePatternFactory.Parse(), which fails for routes starting with~since the stored path lacks the leading/(e.g.,~healthvs/~health).Solution: Add
RoutePatternproperty toApiDescriptionand populate it in both providers:EndpointMetadataApiDescriptionProviderusesrouteEndpoint.RoutePatternDefaultApiDescriptionProviderparses fromAttributeRouteInfo.TemplateMapRelativePathToItemPathuses stored pattern, falls back to parsing for compatibilityExample:
Changes:
RoutePatternproperty toApiDescriptionMapRelativePathToItemPathto use pre-parsed patternTests:
~~routes~routesFixes #60967
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.