Forum Discussion

thmayr's avatar
thmayr
Visitor
4 years ago

Wrong @RequestPart name generated in spring server stub interface

Hello Swagger Folks,

I have the following parameter definition in a multipart/form-data request method:

 

    "/kupo/v1/UploadDateiStream": {
      "post": {
        "tags": [
          "KuPo"
        ],
        "operationId": "KuPo_UploadDateiStream",
        "consumes": ["multipart/form-data"],
        "produces": ["application/xml"],
        "parameters": [
          ...
          {
            "name": "DateiBinary",
            "in": "formData",
            "required": true,
            "type": "File"
          }
        ],

 

In the generated method (language="spring") the parameter looks like this:

 

@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile DateiBinary

 

On the client side (language="java") the following code snippet is generated for the method call:

 

if (dateiBinary != null)
    formParams.add("DateiBinary", new FileSystemResource(dateiBinary));

 

This doesn't obviously not work, because the part name "DateiBinary" generated on the client side doesn't match the expected part name "file" generated on the server side.

How can I influence the part name generated on the server side, which is obviously wrong. The @RequestParam annotations for the other parts containing primitive values are generated with the correct name.

Kind regards

Thomas Mayr

No RepliesBe the first to reply