Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to detect Spring MultipartFile paramter in ApiModel annotated POJOs and show file upload button in Swagger-UI #1370

Closed
roseoxhu opened this issue Jul 1, 2016 · 1 comment
Labels
Milestone

Comments

@roseoxhu
Copy link

roseoxhu commented Jul 1, 2016

I'm using springfox v2.5 for springMVC project, i have an api method expect user upload an attach file.

if i declare MultipartFile in method parameter, springfox can parse correctly and show file upload button,

@RequestMapping(value = "/upload", method = RequestMethod.POST)
@ApiOperation(value="upload attach file", httpMethod = "POST")
public String upload(HttpSession session, HttpServletRequest request,
           @RequestParam MultipartFile attachment) {
        // bala bala
}

but i want a good model structure, move the MultipartFile into a POJO

@ApiModel(description=“POJO model”)
public class Pojo {
      @ApiModelProperty(value = "attach file", required = true)
       private MultipartFile attachment;
}

then modify API method:

@RequestMapping(value = "/upload", method = RequestMethod.POST)
@ApiOperation(value="upload attach file", httpMethod = "POST")
public String upload(HttpSession session, HttpServletRequest request,
           @ModelAttribute Pojo pojo) {
        // bala bala
}

in this case definition, springfox cannot known Pojo's MultipartFile parameter, so the swagger-ui dosen't show the file upload buttion.

@stale
Copy link

stale bot commented Jun 24, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants