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);