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
The JsonPolymorphicAttribute.TypeDiscriminatorPropertyName is nullable. When it's not provided, System.Text.Json defaults to "$type" per the documentation:
Gets or sets a custom type discriminator property name for the polymorhic type. Uses the default '$type' property name if left unset.
When using EnableAnnotations, the built-in AnnotationsDiscriminatorNameSelector method will return a null value if it finds a JsonPolymorphicAttribute where the user hasn't explicitly specified the value (hoping to leverage the defaults). This in turn causes the polymorphism/discriminator/etc. to be completely absent from the generated specification.
The
JsonPolymorphicAttribute.TypeDiscriminatorPropertyName
is nullable. When it's not provided, System.Text.Json defaults to"$type"
per the documentation:When using
EnableAnnotations
, the built-inAnnotationsDiscriminatorNameSelector
method will return anull
value if it finds aJsonPolymorphicAttribute
where the user hasn't explicitly specified the value (hoping to leverage the defaults). This in turn causes the polymorphism/discriminator/etc. to be completely absent from the generated specification.Swashbuckle.AspNetCore/src/Swashbuckle.AspNetCore.Annotations/AnnotationsSwaggerGenOptionsExtensions.cs
Lines 115 to 125 in 0c61531
I believe that the correct behavior would be to coalesce to
"$type"
IIF theJsonPolymorphicAttribute
exists:The text was updated successfully, but these errors were encountered: