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
Two issues: Dictionary<string, int>? in a nullable context is incorrectly described with the int value being nullable. Additionally the behavior of Swashbuckle changes if my property type is IDictionary<string, int>? vs Dictionary<string, int>? (e.g. interface vs concrete).
Expected behavior
If I have a property nullableMapNonNullableValue of type Dictionary<string, int>? or IDictionary<string, int>? on a schema, I would expect the int value to be described as NOT nullable in additionalProperties, like so:
The int value in additionalProperties is incorrectly described as being nullable:
{"nullableMapNonNullableValue": {"type": "object","additionalProperties": {"type": "integer","format": "int32","nullable": true// <-- this is wrong!},"nullable": true}}
If, however, I change the type of the property to be IDictionary<string, int>? (e.g. interface instead of concrete) the behavior changes and the nullability of the int value is now described correctly in additionalProperties:
Describe the bug
Two issues:
Dictionary<string, int>?
in a nullable context is incorrectly described with theint
value being nullable. Additionally the behavior of Swashbuckle changes if my property type isIDictionary<string, int>?
vsDictionary<string, int>?
(e.g. interface vs concrete).Expected behavior
If I have a property
nullableMapNonNullableValue
of typeDictionary<string, int>?
orIDictionary<string, int>?
on a schema, I would expect theint
value to be described as NOT nullable inadditionalProperties
, like so:Actual behavior
The
int
value inadditionalProperties
is incorrectly described as being nullable:If, however, I change the type of the property to be
IDictionary<string, int>?
(e.g. interface instead of concrete) the behavior changes and the nullability of theint
value is now described correctly inadditionalProperties
:Steps to reproduce
I'm submitting a PR with unit tests that fixes both issues.
Exception(s) (if any)
No response
Swashbuckle.AspNetCore version
6.7.0
.NET Version
net8.0
Anything else?
No response
The text was updated successfully, but these errors were encountered: