You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A field annotated with [DataMember(IsRequired = true)] is not marked as required in the generated OpenApi specification.
// class
[DataContract]
public class DataMemberModel
{
[DataMember(Name = "customId", IsRequired = true)]
public string Id;
}
// schema
"DataMemberModel": {
"type": "object",
"properties": {
"customId": { //the id shows that DataMember is indeed used
"type": "string",
"nullable": true
}
},
"additionalProperties": false
}
The "required" status is supposed to be set in NewtonsoftDataContractResolver.GetDataPropertiesFor, using JsonPropertyExtensions.IsRequiredSpecified to know if JsonProperty.Required is readable. But JsonPropertyExtensions.IsRequiredSpecified does not actually look at JsonProperty.Required (which is equals to NotNull in our case). It incorrectly return false.
Swashbuckle.AspNetCore.SwaggerGen 6.3.0
Swashbuckle.AspNetCore.Newtonsoft 6.3.0
A field annotated with [DataMember(IsRequired = true)] is not marked as required in the generated OpenApi specification.
The "required" status is supposed to be set in NewtonsoftDataContractResolver.GetDataPropertiesFor, using JsonPropertyExtensions.IsRequiredSpecified to know if JsonProperty.Required is readable. But JsonPropertyExtensions.IsRequiredSpecified does not actually look at JsonProperty.Required (which is equals to NotNull in our case). It incorrectly return false.
Maybe adding a
if(jsonProperty.Required != Required.Default) return true
at the start of IsRequiredSpecified could be enough.The text was updated successfully, but these errors were encountered: