@@ -21,6 +21,7 @@ internal class EndpointMethodInfoApiDescriptionProvider : IApiDescriptionProvide
2121 private readonly EndpointDataSource _endpointDataSource ;
2222
2323 // Executes before MVC's DefaultApiDescriptionProvider and GrpcHttpApiDescriptionProvider
24+ // REVIEW: Does order matter here? Should this run after MVC?
2425 public int Order => - 1100 ;
2526
2627 public EndpointMethodInfoApiDescriptionProvider ( EndpointDataSource endpointDataSource )
@@ -71,7 +72,7 @@ private static ApiDescription CreateApiDescription(RoutePattern pattern, string
7172
7273 foreach ( var parameter in actionMethodInfo . GetParameters ( ) )
7374 {
74- apiDescription . ParameterDescriptions . Add ( CreateApiParameterDescription ( parameter ) ) ;
75+ apiDescription . ParameterDescriptions . Add ( CreateApiParameterDescription ( parameter , pattern ) ) ;
7576 }
7677
7778 var responseType = actionMethodInfo . ReturnType ;
@@ -91,11 +92,11 @@ private static ApiDescription CreateApiDescription(RoutePattern pattern, string
9192 return apiDescription ;
9293 }
9394
94- private static ApiParameterDescription CreateApiParameterDescription ( ParameterInfo parameter )
95+ private static ApiParameterDescription CreateApiParameterDescription ( ParameterInfo parameter , RoutePattern pattern )
9596 {
9697 var parameterType = parameter . ParameterType ;
9798
98- var ( source , name ) = GetBindingSourceAndName ( parameter ) ;
99+ var ( source , name ) = GetBindingSourceAndName ( parameter , pattern ) ;
99100
100101 return new ApiParameterDescription
101102 {
@@ -108,7 +109,7 @@ private static ApiParameterDescription CreateApiParameterDescription(ParameterIn
108109
109110 // TODO: Share more of this logic with RequestDelegateFactory.CreateArgument(...) using RequestDelegateFactoryUtilities
110111 // which is shared source.
111- private static ( BindingSource , string ) GetBindingSourceAndName ( ParameterInfo parameter )
112+ private static ( BindingSource , string ) GetBindingSourceAndName ( ParameterInfo parameter , RoutePattern pattern )
112113 {
113114 var attributes = parameter . GetCustomAttributes ( ) ;
114115
@@ -137,9 +138,15 @@ private static (BindingSource, string) GetBindingSourceAndName(ParameterInfo par
137138 }
138139 else if ( parameter . ParameterType == typeof ( string ) || RequestDelegateFactoryUtilities . HasTryParseMethod ( parameter ) )
139140 {
140- // TODO: Look at the pattern and infer whether it's really the path or query.
141- // This cannot be done by RequestDelegateFactory currently because of the layering, but could be done here.
142- return ( BindingSource . PathOrQuery , parameter . Name ?? string . Empty ) ;
141+ // Path vs query cannot be determined by RequestDelegateFactory at startup currently because of the layering, but can be done here.
142+ if ( parameter . Name is { } name && pattern . GetParameter ( name ) is not null )
143+ {
144+ return ( BindingSource . Path , name ) ;
145+ }
146+ else
147+ {
148+ return ( BindingSource . Query , parameter . Name ?? string . Empty ) ;
149+ }
143150 }
144151 else
145152 {
0 commit comments