Skip to content

Commit df0ae9e

Browse files
Chris Martinezcommonsensesoftware
Chris Martinez
authored andcommitted
Allow name fallback. Related to #478
1 parent 69bacae commit df0ae9e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Diff for: src/Common.OData.ApiExplorer/AspNet.OData/Routing/ODataRouteBuilder.cs

+8-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.OData.Edm;
1010
using System;
1111
using System.Collections.Generic;
12+
using System.ComponentModel.DataAnnotations.Schema;
1213
using System.Diagnostics.Contracts;
1314
using System.Linq;
1415
using System.Reflection;
@@ -521,12 +522,16 @@ IList<ApiParameterDescription> GetQueryParameters( IList<ApiParameterDescription
521522

522523
static string GetRouteParameterName( IReadOnlyDictionary<string, ApiParameterDescription> actionParameters, string name )
523524
{
525+
if ( !actionParameters.TryGetValue( name, out var parameter ) )
526+
{
527+
return name;
528+
}
524529
#if WEBAPI
525-
return actionParameters[name].ParameterDescriptor.ParameterName;
530+
return parameter.ParameterDescriptor.ParameterName;
526531
#elif API_EXPLORER
527-
return actionParameters[name].ParameterDescriptor.Name;
532+
return parameter.ParameterDescriptor.Name;
528533
#else
529-
return actionParameters[name].Name;
534+
return parameter.Name;
530535
#endif
531536
}
532537

0 commit comments

Comments
 (0)