[Swagger 2.0] Nested Array for parameters in 'formData', 'query', 'path', 'header'?

960 views
Skip to first unread message

mission liao

unread,
Nov 19, 2014, 6:26:49 AM11/19/14
to swagger-sw...@googlegroups.com
Hi,

   I understand that it's reasonable to have nested array for body parameter. But what's the format of nested array for other parameters?
   For example, how to format a nested array into query string?

   p1=[1,2,3,4,5] ->p1=1,2,3,4,5 if collectionFormat == 'cdv'
   p1=[[1,2,3],[4,5,6]] -> ?

Ron

unread,
Nov 19, 2014, 6:36:37 AM11/19/14
to swagger-sw...@googlegroups.com
That's a fair question. The way I see it, the only way to describe it us by using a different collectionFormat for each array.
So [[1,2,3],[4,5,6]] could become 1 2 3, 4 5 6 for example. Of course, you'd need to declare the collectionFormat accordingly.

Is it ugly? Absolutely. Will it work? Well, yes.

--
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.

mission liao

unread,
Nov 19, 2014, 6:49:07 AM11/19/14
to swagger-sw...@googlegroups.com
Oh yes, it seems work in this way. You point a way I didn't see, very appreciate that.
And that's means we would have 4 level array at most(except 'multi')

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

Ron

unread,
Nov 19, 2014, 6:50:47 AM11/19/14
to swagger-sw...@googlegroups.com
yeah. API design-wise, you may want to stay away beyond one level of arrays for such parameters.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

mission liao

unread,
Nov 19, 2014, 7:09:14 AM11/19/14
to swagger-sw...@googlegroups.com
One more question, collectionFormat == 'multi' should be the top level array, right?
{
   type: array,
   items: {
      type: array,
      items: {
         type: integer,
         format: int64,
      },
      collectionFormat: 'csv'
   },
   collectionFormat: 'multi'
}
This one should work. However, if I replace inner collectionFormat with 'multi' and outer one with something else, it seems didn't work, am I right?

On Wednesday, 19 November 2014 19:50:47 UTC+8, Ron R wrote:
yeah. API design-wise, you may want to stay away beyond one level of arrays for such parameters.
On 19 November 2014 13:49, mission liao <mission...@gmail.com> wrote:
Oh yes, it seems work in this way. You point a way I didn't see, very appreciate that.
And that's means we would have 4 level array at most(except 'multi')

On Wednesday, 19 November 2014 19:36:37 UTC+8, Ron R wrote:
That's a fair question. The way I see it, the only way to describe it us by using a different collectionFormat for each array.
So [[1,2,3],[4,5,6]] could become 1 2 3, 4 5 6 for example. Of course, you'd need to declare the collectionFormat accordingly.

Is it ugly? Absolutely. Will it work? Well, yes.
On 19 November 2014 13:26, mission liao <mission...@gmail.com> wrote:
Hi,

   I understand that it's reasonable to have nested array for body parameter. But what's the format of nested array for other parameters?
   For example, how to format a nested array into query string?

   p1=[1,2,3,4,5] ->p1=1,2,3,4,5 if collectionFormat == 'cdv'
   p1=[[1,2,3],[4,5,6]] -> ?

--
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-swaggersocket+unsubscri...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Ron

unread,
Nov 19, 2014, 7:14:39 AM11/19/14
to swagger-sw...@googlegroups.com
right.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages