-
-
Notifications
You must be signed in to change notification settings - Fork 501
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
Browse button for @RequestBody when mediaType is other than application/octet-stream #515
Comments
Please have a look at this page: If you are reporting a bug, please help to speed up problem diagnosis by providing as much information as possible:
|
Thank you @bnasslahsen . These are more details that hopefully help clarify the issue: I am using
|
Hi @jmoraleda, As you can see, if you just change the MediaType (image/png), the browse button will be displayed correctly in the swagger-ui. Also, you can have a look at the specification: |
Hi @bnasslahsen, Thank you for your quick response! I just tried I feel a mechanism for overriding the auto-detected default of whether to use an upload button or an input text box would be very useful because there is a large and growing number of media types and use cases; and in addition, any application can define its own custom media type |
Sorry to hijack this issue but I am trying something similar. My goal is to create an endpoint for uploading larger files. These files should be accepted as a byte-stream s.t. they can be written on-the-fly without consuming too much memory. What I go so far is something like this: @RequestMapping(
value = "/tracks/{trackId}/file",
method = RequestMethod.POST,
consumes = MediaType.APPLICATION_OCTET_STREAM_VALUE
)
@ApiResponse(
description = "Successful Operation",
responseCode = "200",
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE)
)
public @ResponseBody
Track uploadTrackFile(@PathVariable(name = "trackId") Long trackId, HttpServletRequest request) {
return null;
} which produces the following output in the swagger.yaml: /user/tracks/{trackId}/file:
post:
tags:
- track-controller
operationId: uploadTrackFile
parameters:
- name: trackId
in: path
required: true
schema:
type: integer
format: int64
responses:
"200":
description: Successful Operation
content:
application/json: {} This doesn't look right - I'm kind of missing the content:
'*/*':
schema:
$ref: '#/components/schemas/Track' Any idea how I can do this right? |
I have not figured out how to get the swagger-ui to display a Browse button when my
@PostMapping
annotation has aconsumes
attribute with a value other thanapplication/octet-stream
.From the documentation at https://swagger.io/docs/specification/describing-request-body/file-upload/ I have tried to set:
but this makes no difference. The moment I set consumes to a value other than
application/octet-stream
I swagger displays a box to input text instead of a browse button. Am I doing something wrong, or is this a bug?The text was updated successfully, but these errors were encountered: