1

I have a web api which returns a object that contains dictionary property

public Dictionary<int, string> Roles { get; set; }

I use swashbuckle to publish it into 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 swagger format?

daxu
  • 2,775
  • 3
  • 28
  • 53

1 Answers1

4

It's not supported because in the JSON objects/(dictionaries) the keys have to be strings.

Another SO Answer

Community
  • 1
  • 1
Tóth Tibor
  • 1,498
  • 13
  • 21