Skip to content

Conversation

desjoerd
Copy link
Contributor

@desjoerd desjoerd commented Oct 1, 2025

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

…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
@desjoerd desjoerd requested review from captainsafia and a team as code owners October 1, 2025 20:19
@Copilot Copilot AI review requested due to automatic review settings October 1, 2025 20:19
@desjoerd desjoerd requested a review from halter73 as a code owner October 1, 2025 20:19
@github-actions github-actions bot added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Oct 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 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

@desjoerd desjoerd changed the title Fix paths without binding in Minimal Api's not discovered in the Api explorer OpenAPI/ApiExplorer: Fix paths without binding in Minimal Api's not discovered in the Api explorer Oct 1, 2025
@desjoerd desjoerd changed the title OpenAPI/ApiExplorer: Fix paths without binding in Minimal Api's not discovered in the Api explorer OpenAPI/ApiExplorer: Fix paths without binding in Minimal Api's not discovered Oct 1, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Oct 1, 2025
Copy link
Contributor

Thanks for your PR, @@desjoerd. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@desjoerd
Copy link
Contributor Author

desjoerd commented Oct 1, 2025

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 :)

@desjoerd
Copy link
Contributor Author

desjoerd commented Oct 1, 2025

Unit tests added. Let me know what to change or whether this change is desired 👍.

Note for the reviewers:
I moved/changed some test cases which used arrays in the path, that is not supported in the routing so I moved those cases in a new test for query parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates community-contribution Indicates that the PR has been added by a community member feature-openapi
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OpenAPI: Minimal API unused Path parameters are not emitted in the OpenAPI
2 participants