Skip to content

Commit

Permalink
Fix detection on non nullable types to mark as required
Browse files Browse the repository at this point in the history
Because of the higher precedence of the && operator compared to the ??
operator we need to prioritize ?? manually with brackets.
  • Loading branch information
AntiGuideAkquinet committed Apr 16, 2024
1 parent f97d834 commit 646ccee
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ private OpenApiSchema CreateObjectSchema(DataContract dataContract, SchemaReposi
? GenerateSchemaForMember(dataProperty.MemberType, schemaRepository, dataProperty.MemberInfo, dataProperty)
: GenerateSchemaForType(dataProperty.MemberType, schemaRepository);

var markNonNullableTypeAsRequired = dataProperty.MemberInfo?.IsNonNullableReferenceType() ?? false
var markNonNullableTypeAsRequired = (dataProperty.MemberInfo?.IsNonNullableReferenceType() ?? false)
&& _generatorOptions.MarkNonNullableReferenceTypesAsRequired
#if !NETSTANDARD2_0
&& !_mvcOptions.Value.SuppressImplicitRequiredAttributeForNonNullableReferenceTypes
Expand Down

0 comments on commit 646ccee

Please sign in to comment.