0

I'm trying to specify a field, someField, in my swagger docs that is an array of objects. The objects should be key value pairs. The keys are strings with no required name, so a user can name his key whatever he wants. An example would like:

"someField": [{"whatever_key_I_want": "whatever_value_I_want"}, {"whatever_key_I_want2": "whatever_value_I_want2"}]. And this is what I've tried in my swagger yml accordingly.

  someField:
    type: array
    description: This is an array of objects in the form of key-value pairs
    items: 
      type: object
      description: a key value pair
      x-c1-example: 
        any_key_you_want: any_value_you_want

For some reason, though, in the swagger ui, the example shows up as: someField: ["any_key_you_want"=> "any_value_you_want"] instead of someField: ["any_key_you_want": "any_value_you_want"].

Why is : getting changed to =>? How can I fix this?

yalpsid eman
  • 3,064
  • 6
  • 45
  • 71
  • 1
    1) Your definition is correct, but if `"whatever_value_I_want"` values are always strings you should also add `additionalProperties: {type: string}` inside `items`. See [Swagger dictionary parameter definition](https://stackoverflow.com/q/41867499/113116). 2) Where exactly you do see `=>`? Can you post a screenshot? – Helen Aug 11 '20 at 06:43
  • For #2, this shows up in the swagger UI – yalpsid eman Aug 13 '20 at 14:58

0 Answers0