Skip to content

add multipart form upload file, swagger generate json error #1387

@wangzilong

Description

@wangzilong

Hi all:
I use this example https://github.com/swagger-api/swagger-core/tree/v1.3.12/samples/java-jersey2-guice,
add this method in PetResource.java:

    @POST
    @Path("/{petId}/uploadImage")
    @Consumes({MediaType.MULTIPART_FORM_DATA})
    @Produces({MediaType.APPLICATION_JSON})
    @ApiOperation(value = "uploads an image")
    public Response uploadFile(
            @ApiParam(value = "ID of pet to update", required = true) @PathParam("petId") Long petId,
            @ApiParam(value = "Additional data to pass to server") @FormDataParam("additionalMetadata") String testString,
            @ApiParam(value = "file to upload") @FormDataParam("file") InputStream inputStream,
            @ApiParam(value = "file detail") @FormDataParam("file") FormDataContentDisposition fileDetail) {
        return Response.status(200).entity("true").build();
    }

but the scanner generate json is :

...
{
    "path": "/pet/{petId}/uploadImage",
    "operations": [
        {
            "method": "POST",
            "summary": "uploads an image",
            "notes": "",
            "type": "void",
            "nickname": "uploadFile",
            "produces": [
                "application/json"
            ],
            "consumes": [
                "multipart/form-data"
            ],
            "parameters": [
                {
                    "name": "petId",
                    "description": "ID of pet to update",
                    "required": true,
                    "type": "integer",
                    "format": "int64",
                    "paramType": "path",
                    "allowMultiple": false
                },
                {
                    "name": "body",
                    "description": "file detail",
                    "required": false,
                    "type": "FormDataContentDisposition",
                    "paramType": "body",
                    "allowMultiple": false
                }
            ]
        }
    ]
}
...

some thing not work, and miss some parameters.
please help me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions