GC.
GC.

Reputation: 1254

Can Swagger describe an array of complex types in querystring for Microsoft Web API

I am trying to add Swagger doc for my API which uses Microsoft Web API framework.

For example passing an array of GeoPoint (Lat/Lon) objects, Web API expects arrays of complex types that are bound from the querystring to have the following format.

/api/Location?points[0][Lat]=1.2&points[0][Lon]=3.4

This is working.

My question: is it possible to document this collection format and array type in a Swagger JSON document?

I think the relevant spec is here http://swagger.io/specification/#parameterObject

With type=array and collectionFormat=multi it seems to want to repeat the 'points' parameter, but doesn't know about the array index [0] part.

Upvotes: 0

Views: 868

Answers (1)

fehguy
fehguy

Reputation: 6824

not really. First, query parameters in the swagger definition are primitive values, or arrays of primitive values. Next, the assignment of array positions in a query string through substitution is not part of the standard swagger-ui. You can probably make it work, but I suspect none of the other swagger tooling would know what to do with it.

Upvotes: 1

Related Questions