Content-type for POST endpoints with multipart/form-data does not work since v2.4.0
maxdobler opened this issue · comments
Describe the bug
Sind version 2.4.0 POST Endpoints with content-type multipart/form-data
are not generated properly in open api spec. This leads to missing content-type in swagger ui webpage.
To Reproduce
Steps to reproduce the behavior:
-
What version of spring-boot you are using?
3.3.0 -
What modules and versions of springdoc-openapi are you using?
springdoc-openapi-starter-webmvc-ui:2.4.0 -
What is the actual and the expected result using OpenAPI Description (yml or json)?
-
Provide with a sample code (HelloController) or Test that reproduces the problem
POST Endpoint which accepts multipart/form-data. Use [sprin](springdoc-openapi-starter-webmvc-ui in version2.4.0
or2.5.0
@PostMapping(produces = APPLICATION_JSON_VALUE, consumes = MULTIPART_FORM_DATA_VALUE)
Go to swagger-ui webpage and the content-type is missing for the POST Endpoint.
Expected behavior
Adds content-type multipart/form-data to POST Endpoints in OpenApi docs
Additional context
Not reproducible.
Feel free to provide a Minimal, Reproducible Example - with HelloController that reproduces the problem.
This ticket will be closed, but can be reopened if your provide the reproducible sample.
I created an example to reproduce the bug: https://github.com/maxdobler/springdoc-example
I noticed that it makes a difference if the UploadDto
has the @Valid
annotation. With the annotation, the swagger-ui displays the dropdown an displayes the right content-type.
If you change the springdoc version to 2.5.0
the consuming content-type is not displayed in the swagger-ui.
Please reopen this issue.
@bnasslahsen Please reopen this issue
This behavior was a bug in previous versions. In version 2.5.0, the workaround is to explicitly declare @RequestBody
.
@Operation(summary = "Upload new content", description = "Upload test content")
@PostMapping(produces = APPLICATION_JSON_VALUE, consumes = MULTIPART_FORM_DATA_VALUE)
HelloDto uploadContent(@RequestBody HelloUploadDto contentUploadDto) throws IOException;
Oh I see, thank you for the fast Feedback. It now works with @RequestBody
. 👍