Skip to content

Commit 1ef1899

Browse files
author
Chris Martinez
committed
Fixed NRE when parameter that does not have model metadata is encountered. Fixes #250
1 parent 9e96645 commit 1ef1899

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer/ApiVersionParameterDescriptionContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ void RemoveAllParametersExcept( ApiParameterDescription parameter )
249249

250250
foreach ( var otherParameter in otherParameters )
251251
{
252-
if ( otherParameter.ModelMetadata.DataTypeName == nameof( ApiVersion ) )
252+
if ( otherParameter.ModelMetadata?.DataTypeName == nameof( ApiVersion ) )
253253
{
254254
collection.Remove( otherParameter );
255255
}

src/Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer/Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
<ItemGroup>
1616
<ReleaseNotes Include="Support substituting API version parameter in route templates (Issue 247)" />
17+
<ReleaseNotes Include="Fix NullReferenceException when parameter without metadata is encountered (Issue 250)" />
1718
</ItemGroup>
1819

1920
<ItemGroup>

0 commit comments

Comments
 (0)