ITADN

[Bug]: Dictionary with values of type object generates invalid open api schema

#3936Closedldeluigi 创建于 2026-04-30
bug
L
ldeluigicommented
### Describe the bug The schema generation for a value of type `IDictionary<XXX, object>` or `IImmutableDictionary<XXX, object>` puts the wrong schema type on the property values. The type of the properties of the dictionary is just 'null' instead of a list with object and 'null'. ### Expected behavior The property type of a `IDictionary<XXX, object>` or `IImmutableDictionary<XXX, object>` should be object or at worst object and 'null' ### Actual behavior System.Object data contract is dynamic. A dynamic data contract as json schema type "unknown". An unknown json schema type within a data contract will produce an open api schema whose type is null. Within the dictionary property open api schema generator, you attempt to add nullable to the types of the open api schema, and you replace null with Nullable if the value is null. As a result, the type of the properties of the dictionary is just 'null' instead of a list with object and 'null'. ### Steps to reproduce _No response_ ### Exception(s) (if any) _No response_ ### Swashbuckle.AspNetCore version 10.1.7 ### .NET Version 10 ### Anything else? I think this is a regression. Before, `IDictionary<XXX, object>` would have had non nullable properties and as such the issue didn't appear
关闭于 2026-07-20 4 条评论