Which version of swagger-core are you using?

 

 

 

From: <[email protected]> on behalf of Horaci Macias 
<[email protected]>
Reply-To: "[email protected]" 
<[email protected]>
Date: Wednesday, 23 November 2016 at 4:30
To: Swagger <[email protected]>
Subject: swagger-ui and multipart form file uploads

 

Hi everybody, 

 

I'm trying to use swagger-ui and annotations to document my REST java backed.

For some reason the generated swagger.json has a duplicate parameter for the 
file.

 

If I use the following java code/annotations:

 

@POST
@Path("/fileupload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@ApiOperation(
      value = "Imports CSV file",
      notes = "Bulk imports all users from CSV file into database."
)
@ApiResponses({
      @ApiResponse(code = 200, message = "Import successful"),
      @ApiResponse(code = 500, message= "Error importing file")
})
@ApiImplicitParams(@ApiImplicitParam(dataType = "file", name = "upload", 
paramType = "formData", required = true))
public Response uploadFile(@ApiParam(hidden = true, name = "upload") 
@FormParam("upload") File upload) {
 

this is the json generated:

 

    "/users/fileupload" : {

      "post" : {

        "tags" : [ "Users" ],

        "summary" : "Imports CSV file",

        "description" : "Bulk imports all users from CSV file into database.",

        "operationId" : "uploadFile",

        "consumes" : [ "multipart/form-data" ],

        "produces" : [ "application/json" ],

        "parameters" : [ {

          "name" : "upload",

          "in" : "formData",

          "required" : false,

          "type" : "string"

        }, {

          "name" : "upload",

          "in" : "formData",

          "required" : true,

          "type" : "file"

        } ],

        "responses" : {

          "200" : {

            "description" : "Import successful"

          },

          "500" : {

            "description" : "Error importing file"

          }

        }

      }

    },

 

which swagger-ui shows as a duplicate parameter, one being required (the file 
upload which is the only one I want to see) and another non-required of data 
type "String":

Does anybody have a working example of this same scenario? how can I make sure 
swagger-ui just shows a single "upload" parameter of type "file" ?

 

thanks,

 

H

 

-- 
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 [email protected].
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to