Hi,
I have a service defined like :
@PostMapping(path = "/documents")
public ResponseEntity<String> uploadDocuments(
@RequestParam("doc") List<MultipartFile> multipartFiles,
@RequestParam(value = "mode", required = false, defaultValue = edit) String mode)
Generated YAML file contains MultipartFile schema :
schemas:
MultipartFile:
type: object
properties:
name:
type: string
empty:
type: boolean
bytes:
type: array
items:
type: string
format: byte
resource:
$ref: '#/components/schemas/Resource'
size:
type: integer
format: int64
inputStream:
type: object
contentType:
type: string
originalFilename:
type: string
Resource:
type: object
properties:
open:
type: boolean
file:
type: string
format: binary
readable:
type: boolean
description:
type: string
uri:
type: string
format: uri
filename:
type: string
url:
type: string
format: url
inputStream:
type: object
So the UI doesn't recognize the field as binary so I can't upload images.

YAML THAT WORKS
If the schema was :
schemas:
MultipartFile:
type: string
format: binary

How can I override this generated MultipartFile? Or there is some other solution I'm missing?
I'm using:
`
Hi,
File upload was not handled by the springdoc-openapi-core.
Hey, I tried it. Now I'm getting YAML part looking like :
parameters:
- name: doc
in: query
required: true
schema:
type: object
properties:
files:
type: array
items:
type: string
format: binary
And it still doesn't show good in UI.
YAML THAT WORKS
parameters:
- name: doc
in: query
required: true
schema:
type: array
items:
type: string
format: binary
I'm using springdoc-openapi-core and springdoc-openapi-ui version 1.1.6
Hello,
Your swagger shows the file is passed as @RequestParam,.
For the file upload, just use @RequestPart instead, which is more appropriate in the spring. And it should work.
@PostMapping (path = "/documents") public ResponseEntityString> upload Documents (@RequestPart ("doc") ListMultipartFile> multipartFiles, @RequestParam (value = "mode", required = false, defaultValue = edit) String mode)
Or even without any annotations, just giving the parameter the right name. ("doc" in your case)
@PostMapping (path = "/documents") public ResponseEntityString> upload Documents (ListMultipartFile> doc, @RequestParam (value = "mode", required = false, defaultValue = edit) String mode)
Thanx, you are right! Changed it to "@RequestParam" but also in "@PostMapping" added option consumes = "multipart/form-data". And it looks good

Most helpful comment
Hello,
Your swagger shows the file is passed as @RequestParam,.
For the file upload, just use @RequestPart instead, which is more appropriate in the spring. And it should work.
@PostMapping (path = "/documents") public ResponseEntityString> upload Documents (@RequestPart ("doc") ListMultipartFile> multipartFiles, @RequestParam (value = "mode", required = false, defaultValue = edit) String mode)Or even without any annotations, just giving the parameter the right name. ("doc" in your case)
@PostMapping (path = "/documents") public ResponseEntityString> upload Documents (ListMultipartFile> doc, @RequestParam (value = "mode", required = false, defaultValue = edit) String mode)