-
Notifications
You must be signed in to change notification settings - Fork 10.5k
OpenAPI/ApiExplorer: Fix paths without binding in Minimal Api's not discovered #63897
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
…i explorer Paths without a binding would be omitted by the EndpointMetadataApiDescriptionProvider. Some tests around OpenApi required fixing as arrays are not supported in paths. Fixes dotnet#63883
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 addresses an issue where paths without binding in Minimal APIs were not being discovered in the API explorer. The fix ensures route parameters are properly tracked and adds missing ones to the API description when they aren't associated with delegate parameters.
Key changes:
- Modified EndpointMetadataApiDescriptionProvider to track and add unbound route parameters
- Removed array parameter test cases from path parameter tests since arrays aren't supported in path parameters
- Added comprehensive test coverage for query parameters and validation attributes
- Enhanced test assertions to verify parameter location (Path vs Query)
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/Mvc/Mvc.ApiExplorer/src/EndpointMetadataApiDescriptionProvider.cs | Core fix to track remaining route parameters and add them to API description |
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.ParameterSchemas.cs | Updated tests to remove invalid array path parameters, added query parameter tests, and enhanced assertions |
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/OperationTests.MinimalApis.cs | Added test case for route parameters from Minimal APIs |
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/OperationTests.SupportsRouteParametersFromMinimalApis#OpenApiXmlCommentSupport.generated.verified.cs | Generated snapshot file for XML comment support |
Thanks for your PR, @@desjoerd. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Tests will fail till #63872 is merged, as that adds the correct condition for path parameters without model metadata. I am adding unit tests for the ApiExplorer, just looking at how does fit together :) |
Unit tests added. Let me know what to change or whether this change is desired 👍. Note for the reviewers: |
Paths without a binding would be omitted by the EndpointMetadataApiDescriptionProvider. Some tests around OpenApi required fixing as arrays are not supported in paths.
Fixes #63883