From 21014ec80792b8ef0a9a1f611bc032b0c06d7797 Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 24 Feb 2021 16:59:20 +0800 Subject: [PATCH] Handle null value. --- .../Mvc/AspNetCoreApiDescriptionModelProviderOptions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProviderOptions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProviderOptions.cs index ba5041a067..f807efcfdf 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProviderOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProviderOptions.cs @@ -63,14 +63,14 @@ namespace Volo.Abp.AspNetCore.Mvc if (apiParameterDescription.ModelMetadata is DefaultModelMetadata defaultModelMetadata) { var jsonPropertyNameAttribute = (System.Text.Json.Serialization.JsonPropertyNameAttribute) - defaultModelMetadata.Attributes.PropertyAttributes.FirstOrDefault(x => x is System.Text.Json.Serialization.JsonPropertyNameAttribute); + defaultModelMetadata?.Attributes?.PropertyAttributes?.FirstOrDefault(x => x is System.Text.Json.Serialization.JsonPropertyNameAttribute); if (jsonPropertyNameAttribute != null) { return jsonPropertyNameAttribute.Name; } var jsonPropertyAttribute = (Newtonsoft.Json.JsonPropertyAttribute) - defaultModelMetadata.Attributes.PropertyAttributes.FirstOrDefault(x => x is Newtonsoft.Json.JsonPropertyAttribute); + defaultModelMetadata?.Attributes?.PropertyAttributes?.FirstOrDefault(x => x is Newtonsoft.Json.JsonPropertyAttribute); if (jsonPropertyAttribute != null) { return jsonPropertyAttribute.PropertyName;