swagger-api/swagger-codegen

Improper function parameters in client code generated for file upload (Image)

Open

#5,573 创建于 2017年5月5日

在 GitHub 查看
 (5 评论) (0 反应) (0 负责人)HTML (12,701 star) (5,474 fork)batch import
Issue: BugServer: Javahelp wanted

描述

Description

A generated post method (JAX-RS code) which takes 2 query parameters of string type and 2 @FormDataParam one for InputStream and one for FormDataContentDisposition for file object. There is client code generated which takes 3 parameters , one File parameter object and two string datatype values. The flow goes like this , A call is made to the POST Rest call which inturn makes call to the generated API client and from there to 3 rd party service (In my case it is watson service). My doubt here is that the code is failing when i try to build with the below exception

class com.ibm.mfp.adapters.sample.api.VisualRecognitionApi cannot be applied to given types; required: java.lang.String,java.io.File,java.lang.String,java.lang.String found: java.lang.String,java.io.InputStream,com.sun.jersey.core.header.FormDataContentDisposition,java.lang.String,java.lang.String,javax.ws.rs.core.SecurityContext reason: actual and formal argument lists differ in length

Server code generated :

@POST @Path("/detect_faces") @Consumes({ "multipart/form-data" }) @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "Detect faces in an image", notes = "", response = Faces.class, tags={ "VisualRecognition" })@io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "success", response = Faces.class), @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid request", response = Faces.class) }) @OAuthSecurity(enabled=false) public Response v3DetectFacesPost(@ApiParam(value = "API Key used to authenticate.")@QueryParam("api_key") String apiKey, @FormDataParam("file") InputStream fileInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail , @ApiParam(value = "")@FormDataParam("parameters") String parameters ,@ApiParam(value = "") @DefaultValue("2016-05-20") @QueryParam("version") String version ,@Context SecurityContext securityContext),throws NotFoundException, ServiceFactoryFinderException { com.ibm.mfp.adapters.sample.ApiClient apiAuthInstance = new com.ibm.mfp.adapters.sample.ApiClient(); com.ibm.mfp.adapters.sample.api.VisualRecognitionApi apiInstance = new com.ibm.mfp.adapters.sample.api.VisualRecognitionApi(apiAuthInstance);

result = apiInstance.v3DetectFacesPost(apiKey,fileInputStream, fileDetail,parameters,version,securityContext);

Java Client code generated

public Faces v3DetectFacesPost(String apiKey, File file, String parameters, String version) throws ApiException { ApiResponse<Faces> resp = v3DetectFacesPostWithHttpInfo(apiKey, file, parameters, version); return resp.getData(); }

is the client code generated correct ??

Swagger-codegen version

version of swagger-codegen : 2.2.2

Swagger declaration file content or url
"post": {
                "summary": "Detect faces in an image",
                "tags": [
                    "VisualRecognition"
                ],
		 "consumes": [ "multipart/form-data" ],
    		 "produces": [ "application/json"],
                "parameters": [
                    {
                        "$ref": "#/parameters/ApiKeyParam"
                    },
                    {
                        "name": "file",
            			"in": "formData",
           				 "description": "The image file (.jpg, .png) or compressed (.zip) file of images.  The total number of images is limited to 20, with a max .zip size of 5 MB.",
           				 "required": false,
            			"type": "file"
                    },
                    {
                        "$ref": "#/parameters/URLsOnlyConfigParam"
                    },
                    {
                        "$ref": "#/parameters/DateVersionParam"
                    }
                ]
  }

Please let me know your input on this

贡献者指南

Improper function parameters in client code generated for file upload (Image) · swagger-api/swagger-codegen#5573 | Good First Issue