javaswaggerjerseydocumentation

Swagger API for MultivaluedMap Jersey? Is it possible?


Is it possible to made API documentation by annotations for MultivaluedMap param in Jersey using Swagger?

I have a little piece of code like this:

/**
 * Method which serves requests of adding {@link StudentGroup} to DB
 * 
 * @param name
 * @param description
 * @return {@link Response}
 * @throws RestServiceException
 */
 @POST
 @Path("/add")
 public Response addStudentGroup(MultivaluedMap<String, String> formParams) throws 
     RestServiceException {
     String name = formParams.getFirst("name");
     String description = formParams.getFirst("description");
     String studentIds = formParams.getFirst("studentIds");

     (...)

}

and I want to use @ApiParam to generate JSON with documentation data using Swagger and Swagger UI.

If I put @ApiParam before MultivaluedMap<String, String> formParams it doesn't work. Swagger can not list any params.


Solution

  • It seems like this is a bug in Swagger - I also get this behavior. Using other generic classes with two type parameters (like @ApiParam() HashMap) works fine. Probably it throws the parser off.

    I opened an issue for this on the Swagger bug tracking system.

    You can also ask them on their Google group or find them on IRC at Freenode#swagger.