Reputation: 4074
I have a Web API which returns a object that contains a dictionary property with integer keys:
public Dictionary<int, string> Roles { get; set; }
I use Swashbuckle to publish it into OpenAPI/Swagger format and this is what I get:
"Roles": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
I am not really sure this is correct? As there is no indication that my dictionary key is an integer.
How can represent my dictionary correctly in OpenAPI?
Upvotes: 2
Views: 6701
Reputation: 1565
It's not supported because in the JSON objects/(dictionaries) the keys have to be strings.
Upvotes: 5