Skip to content

Commit

Permalink
fix(NRE): Fix small bug
Browse files Browse the repository at this point in the history
  • Loading branch information
unchase committed Aug 26, 2021
1 parent 14f2d7d commit b67a264
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ internal static void ApplyPropertyComments(
bool includeRemarks = false,
params Type[] excludedTypes)
{
if (memberInfo == null)
{
return;
}

string memberName = XmlCommentsNodeNameHelper.GetMemberNameForFieldOrProperty(memberInfo);

if (!inheritedDocs.ContainsKey(memberName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,23 @@ public void Apply(OpenApiParameter parameter, ParameterFilterContext context)
return;
}

if (context.ApiParameterDescription.PropertyInfo() == null)
{
return;
}

// Try to apply a description for inherited types.
string parameterMemberName = XmlCommentsNodeNameHelper.GetMemberNameForFieldOrProperty(context.ApiParameterDescription.PropertyInfo());
if (string.IsNullOrEmpty(parameter.Description) && _inheritedDocs.ContainsKey(parameterMemberName))
{
string cref = _inheritedDocs[parameterMemberName];
var target = context.ApiParameterDescription.PropertyInfo().GetTargetRecursive(_inheritedDocs, cref);

if (target == null)
{
return;
}

var targetXmlNode = XmlCommentsExtensions.GetMemberXmlNode(XmlCommentsNodeNameHelper.GetMemberNameForFieldOrProperty(target), _documents);
var summaryNode = targetXmlNode?.SelectSingleNode(SummaryTag);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public void Apply(OpenApiParameter parameter, ParameterFilterContext context)

private void ApplyPropertyTags(OpenApiParameter parameter, PropertyInfo propertyInfo)
{
if (propertyInfo == null)
{
return;
}

if (propertyInfo.DeclaringType != null && _excludedTypes.Any() && _excludedTypes.ToList().Contains(propertyInfo.DeclaringType))
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ public void Apply(OpenApiRequestBody requestBody, RequestBodyFilterContext conte

private void ApplyPropertyTags(OpenApiRequestBody requestBody, PropertyInfo propertyInfo)
{
if (propertyInfo == null)
{
return;
}

if (propertyInfo.DeclaringType != null && _excludedTypes.Any() && _excludedTypes.ToList().Contains(propertyInfo.DeclaringType))
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ private void ApplyTypeTags(OpenApiSchema schema, Type type)

private void ApplyFieldOrPropertyTags(OpenApiSchema schema, MemberInfo fieldOrPropertyInfo)
{
if (fieldOrPropertyInfo == null)
{
return;
}

if (fieldOrPropertyInfo.DeclaringType != null && _excludedTypes.Any() && _excludedTypes.ToList().Contains(fieldOrPropertyInfo.DeclaringType))
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<NeutralLanguage></NeutralLanguage>
<LangVersion>7.3</LangVersion>
<PackageIconUrl>https://github.com/unchase/Unchase.Swashbuckle.AspNetCore.Extensions/blob/master/assets/icon.png?raw=true</PackageIconUrl>
<Version>2.6.3</Version>
<AssemblyVersion>2.6.3.0</AssemblyVersion>
<FileVersion>2.6.3.0</FileVersion>
<Version>2.6.4</Version>
<AssemblyVersion>2.6.4.0</AssemblyVersion>
<FileVersion>2.6.4.0</FileVersion>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<DocumentationFile>Unchase.Swashbuckle.AspNetCore.Extensions.xml</DocumentationFile>
</PropertyGroup>
Expand Down

0 comments on commit b67a264

Please sign in to comment.