How can I set "collectionFormat" using swagger annotation?

1,415 views
Skip to first unread message

Vic

unread,
Dec 14, 2016, 9:10:21 PM12/14/16
to Swagger
Hi,

I'm using swagger-annotaions-1.5.10 and swagger-maven-plugin 3.1.0 to generate swagger.json and client code during maven build.

For query parameter "@QueryParam("mid") List<UUID> mids", to make client SDK send something like "mid=1&mid=2" rather than "mid=1,2", 
"collectionFormat" should be "multi" rather the default "csv".

While I can't find a corresponding filed in @ApiParam and @ApiImplicitParam, does anyone know how to do? Thanks.

Regards,
Vic

 

Vic

unread,
Dec 14, 2016, 9:12:31 PM12/14/16
to Swagger
Below is from the auto-generated swagger spec.

{
    "name": "mid",
    "in": "query",
    "required": false,
    "type": "array",
    "items": {
        "type": "string",
        "format": "uuid"
    },
    "collectionFormat": "csv" // HOW TO CHANGE IT?
}

tony tam

unread,
Dec 15, 2016, 8:36:25 AM12/15/16
to swagger-sw...@googlegroups.com
Hi, the collection format is not supported via annotations, it should default to “multi” which I believe is the default format for JAXRS arrays.

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

Vic

unread,
Dec 15, 2016, 5:21:35 PM12/15/16
to Swagger
Hi Tony,

Thanks for your reply, while what I got is "csv", it's weird.

Regards,
Vic


On Friday, December 16, 2016 at 2:36:25 AM UTC+13, tony tam wrote:
Hi, the collection format is not supported via annotations, it should default to “multi” which I believe is the default format for JAXRS arrays.
On Dec 14, 2016, at 6:12 PM, Vic <vic.li...@gmail.com> wrote:

Below is from the auto-generated swagger spec.

{
    "name": "mid",
    "in": "query",
    "required": false,
    "type": "array",
    "items": {
        "type": "string",
        "format": "uuid"
    },
    "collectionFormat": "csv" // HOW TO CHANGE IT?
}

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

Ron Ratovsky

unread,
Dec 18, 2016, 7:29:09 AM12/18/16
to swagger-sw...@googlegroups.com

That could be a bug with the swagger-maven-plugin. You should open a ticket on that project.

 

 

 

From: <swagger-sw...@googlegroups.com> on behalf of Vic <vic.li...@gmail.com>
Reply-To: "swagger-sw...@googlegroups.com" <swagger-sw...@googlegroups.com>
Date: Thursday, 15 December 2016 at 23:21
To: Swagger <swagger-sw...@googlegroups.com>
Subject: Re: How can I set "collectionFormat" using swagger annotation?

 

Hi Tony,

 

Thanks for your reply, while what I got is "csv", it's weird.

 

Regards,

Vic

On Friday, December 16, 2016 at 2:36:25 AM UTC+13, tony tam wrote:

Hi, the collection format is not supported via annotations, it should default to “multi” which I believe is the default format for JAXRS arrays.

On Dec 14, 2016, at 6:12 PM, Vic <vic.li...@gmail.com> wrote:

 

Below is from the auto-generated swagger spec.

 

{

    "name": "mid",

    "in": "query",

    "required": false,

    "type": "array",

    "items": {

        "type": "string",

        "format": "uuid"

    },

    "collectionFormat": "csv" // HOW TO CHANGE IT?

}

 

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

 

--

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.

Vic

unread,
Dec 22, 2016, 8:45:22 PM12/22/16
to Swagger
Hi Ron, according to the spec http://swagger.io/specification/, collectionFormat default value is "csv". Looks like no way to change it using annotation for now.

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


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

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

Ron Ratovsky

unread,
Dec 22, 2016, 9:06:03 PM12/22/16
to swagger-sw...@googlegroups.com

The default value is irrelevant.  It’s up to the tool to know which value fits to the situation, and the maven plugin doesn’t translate it correctly.

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.

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

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

Vic

unread,
Dec 27, 2016, 2:43:34 PM12/27/16
to Swagger
yes, you're correct.

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


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

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


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

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

Reply all
Reply to author
Forward
0 new messages