Sitelet https://github.com/springfox/springfox/issues/3527
Skip to content

Example and description for @requestpart #3527

Description

@uuk007

The requirement is a user will upload files to spring boot (ReST request) using angular. The ReST interface store the file into gitlab for further processing. Using @RequestPart annotation, content with a different name will be retrieved from a request and placed into Gitlab. The ReST implementation as follows:

@ApiOperation(value = "Upload java files into Gitlab")
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE,
 produces = "application/json")
@ApiResponses(value = { @ApiResponse(code = 200, response = CustomResponse.class, message = "Success"),
        @ApiResponse(code = 400, response = ErrorResponse.class, message = "Bad Request"),
        @ApiResponse(code = 500, response = ErrorResponse.class, message = "Internal Server Error") })

public CustomResponse uploadJava(
        @ApiParam(value = "Interface", required = true)
        @RequestPart(name = "interface", required = true) final MultipartFile interfaceClass,
        @ApiParam(value = "Java Class", required = false) 
        @RequestPart(name = "javaClass", required = false) final MultipartFile javaClass) {
    return null;

When I access the Swagger UI, couldn't find description and example

I found the following in github forum stating that it will resolve the above issue

@parameter( description = "This is the configuration", content = @content(mediaType = MediaType.APPLICATION_JSON_VALUE))

But it didn't.

My question is,

  1. How to add description and example for the above. (Similar to RequestParam)
  2. How to set content type for each file.

Swagger dependency in my project:

    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-boot-starter</artifactId>
        <version>3.0.0</version>
    </dependency>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions