From adb9352122a733df90d95018b1b4e6a1d851b96f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Bornsj=C3=B6?= Date: Thu, 11 Mar 2021 12:39:31 +0100 Subject: [PATCH] Fixed missing parenthesis that could cause a property to be added as required multiple times. --- .../SchemaGenerator/SchemaGenerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs index 922ab81e8d..0a88a6b2ad 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs @@ -374,7 +374,7 @@ private OpenApiSchema CreateObjectSchema(DataContract dataContract, SchemaReposi ? GenerateSchemaForMember(dataProperty.MemberInfo, schemaRepository, dataProperty) : GenerateSchemaForType(dataProperty.MemberType, schemaRepository); - if (dataProperty.IsRequired || customAttributes.OfType().Any() + if ((dataProperty.IsRequired || customAttributes.OfType().Any()) && !schema.Required.Contains(dataProperty.Name)) { schema.Required.Add(dataProperty.Name);