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

A HTTP header in multipart/form-data is handled as form item instead of header #1842

Closed
jarekkar opened this issue Sep 13, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@jarekkar
Copy link

Describe the bug
A HTTP header in multipart/form-data is handled as form item instead of header

To Reproduce

  • java: 17
  • spring-boot: 2.7.3
  • springdoc-openapi: 1.6.11
  • actual OpenAPI description: openjson.txt
"multipart/form-data" : {
    "schema" : {
        "required" : [ "file", "request" ],
        "type" : "object",
        "properties" : {
            "request" : {
                "$ref" : "#/components/schemas/GreetRequest"
            },
            "file" : {
                "type" : "string",
                "format" : "binary"
            },
            "My-Header" : { }
        }
    }
}
  • Sample controller:
@Operation(summary = "Test Endpoint")
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(OK)
GreetResponse upload(
    @RequestHeader("My-Header") String workspaceId,
    @RequestPart("request") GreetRequest request,
    @RequestPart("file") MultipartFile file
) {
    return GreetResponse.of("Hello World!");
}

record GreetRequest(String message1, String message2, String message3) {

}

record GreetResponse(String message) {

    static GreetResponse of(String message) {
        return new GreetResponse(message);
    }
}

Expected behavior

  • A HTTP header in multipart/form-data should be handled as a header not form item

Screenshots

image

bnasslahsen added a commit that referenced this issue Oct 14, 2022
@bnasslahsen
Copy link
Contributor

@jarekkar,

This is a regression. The workaround is to use:

springdoc.default-support-form-data=false

It will be fixed for next release.

@bnasslahsen bnasslahsen added the bug Something isn't working label Oct 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants