-
-
Notifications
You must be signed in to change notification settings - Fork 524
Wrong schema generation on endpoint consuming multipart form data combined with JsonView #1829
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
Comments
I have similar issue, since version 1.6.10 all Example: @PostMapping(value = "/bitmap", consumes = "multipart/form-data", produces = "application/json")
public ImageInfoDTO uploadImage(
@Parameter(description = "Uploaded image", required = true) @RequestPart MultipartFile file,
@Parameter(description = "File access restriction (default is OWNER_ONLY)") @RequestParam Access access
) { ... } Produces: {
"paths": {
"/bitmap": {
"post": {
"tags": [
"Image"
],
"operationId": "uploadImage",
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"required": [
"file"
],
"type": "object",
"properties": {
"file": {
"type": "string",
"description": "Uploaded image",
"format": "binary"
},
"access": {
"description": "File access restriction (default is OWNER_ONLY)"
}
}
}
}
}
},
"responses": {...}
}
}
}
} Expected behaviour: |
Same still on 1.6.11, I have discovered that just yesterday |
Workaround is to use: springdoc.default-support-form-data=false This will be the default behavior, starting from |
Issue reported in comment by mdjimy is indeed fixed, but what about my issue with wrong schema when using JsonView? Actual controller that I'm using contains also MultipartFile, so that would be more precise reporduction: @PostMapping(value = "/foo", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@JsonView(ViewB.class)
public Foo postFoo(@RequestPart("input") @JsonView(ViewA.class) Foo foo,
@RequestPart("file") MultipartFile file) {
return null;
} Maybe your fix doesn't cover that case so it would be my fault by providing inaccurate reproduction step so sorry for that. |
Describe the bug
When using method consuming MediaType.MULTIPART_FORM_DATA_VALUE, schemas for RequestPart objects are generated based on JsonView from method level, which should be related only to response schema, instead of parameter level
To Reproduce
Steps to reproduce the behavior:
HelloController:
Foo:
/v3/api-docs:
Analogically, when no JsonView annotation is present on method level then the only generated shema is Foo with properties a and b and both input and response objects refer to that schema, ignoring JsonView(ViewA.class) on parameter
Expected behavior
The text was updated successfully, but these errors were encountered: