How do a specify that a parameter is a Map?

1,694 views
Skip to first unread message

Chris Cleveland

unread,
May 20, 2014, 1:58:35 PM5/20/14
to swagger-sw...@googlegroups.com
I'm having a hard time finding documentation on container types. Suppose my rest method takes a parameter which is a Map of name/value pairs. The specific names are not known in advance, so we can't use a Model. Can I do something like this?

"parameters": [
  {
    "name": "myMap",
    "type": "Map",
    "paramType": "body"
  }
]

A related question: I've seen sample Swagger specs where the "type" is "array", and others where it's "List". What's the difference?

I cannot find any comprehensive documentation of what's allowed for "type" in the Swagger 1.2 spec.

Ron

unread,
May 21, 2014, 7:42:05 AM5/21/14
to swagger-sw...@googlegroups.com
Hi Chris,

Swagger doesn't support Map types. Documentation-wise, it wouldn't make a lot of sense since what would the end user do with 'this is a Map, but I'm not telling you what to send with it!'.
That said, you *can* emulate a Map by having an object with two fields - key and value, and then have an array of those objects.

Type "List" was used in older version of the swagger specification and all container types were replaced with "array" in version 1.2.

You can find all the information you need about 1.2 data types here - https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#43-data-types



--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages