Forum Discussion

onikudaki's avatar
onikudaki
Occasional Visitor
6 years ago

Swagger document, defining response for complex type in 2.0

Hi folks,

I am hoping that someone can assist me with how to define my response data set in 2.0

 

I have managed to sort everything else, however in one of the response types, i need to return the following type of data

 


{
  "undetermined text string": {
     "Count": 14,
     "Value": 40
   },
  "undetermined text string": {
     "Count": 23,
     "Value": 3
   },
  "NotifyResult": 0,
  "Value": 0
}

 

 

There can be any number of "undetermined text string" entires, before the "NotifyResult"

I have tried all of the things i can think of, but am at a loss with this atm

 

regards

 

 

 

1 Reply

  • You can use additionalProperties to describe arbitrary key names.

     

     

    additionalProperties:
      type: object
      properties:
        Count:
          type: integer
        Value:
          type: integer

    Or alternatively:

    additionalProperties:
      $ref: '#/definitions/MyCommonModel'

    Where MyCommonModel will be the definition of the value object used here.