Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -350,16 +350,18 @@ private OpenApiSchema CreateArraySchema(DataContract dataContract, SchemaReposit

private OpenApiSchema CreateDictionarySchema(DataContract dataContract, SchemaRepository schemaRepository)
{
if (dataContract.DictionaryKeys != null)
var knownKeysProperties = dataContract.DictionaryKeys?.ToDictionary(
name => name,
_ => GenerateSchema(dataContract.DictionaryValueType, schemaRepository));

if (knownKeysProperties?.Count > 0)
{
// This is a special case where the set of key values is known (e.g. if the key type is an enum)
return new OpenApiSchema
{
Type = "object",
Properties = dataContract.DictionaryKeys.ToDictionary(
name => name,
name => GenerateSchema(dataContract.DictionaryValueType, schemaRepository)),
AdditionalPropertiesAllowed = false,
Properties = knownKeysProperties,
AdditionalPropertiesAllowed = false
};
}
else
Expand Down