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

[java] File uploads in multipart/form-data request body's are generated as a byte[] argument instead of File #150

Closed
lion7 opened this issue Aug 9, 2018 · 1 comment

Comments

@lion7
Copy link
Contributor

lion7 commented Aug 9, 2018

When attempting to specify file uploads in a multipart/form-data schema the Java generator will generate a method that takes a byte[] argument. But the OpenAPI Specification 3.0 states that byte arrays are properties defined as:

requestBody:
  content:
    multipart/form-data:
      schema:
        type: object
        properties:
          myByteArray:
            type: string
            format: byte

Specifying a binary type such as a file upload can be defined by using the binary format:

requestBody:
  content:
    multipart/form-data:
      schema:
        type: object
        properties:
          myFileUpload:
            type: string
            format: binary

I'd expect that in the generated Java code this would be a java.util.File argument. That way the used HTTP client can properly determine the Content-Type and Content-Disposition headers, where the latter contains the filename. These headers are both mandatory when submitting a file upload according to the multipart specification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant