Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[JAVA] [Swift5] multipart/form-data upload with multiple files in one field #9839

Open
@JohannesKuehnel

Description

Description

The official Swagger 2.0 documentation states binary string arrays as the workaround for specifying a multipart/form-data upload with multiple files in one field (like a file array).

However, uploading an arbitrary number of files (an array of files) is not supported. There is an open feature request at OAI/OpenAPI-Specification#254. For now, you can use a binary string array as a workaround for uploading an arbitrary number of files:

type: array
items:
 type: string
 format: binary

Swagger UI already has problems correctly rendering this type, but code generation (for Java okhttp-gson and Swift5 at least) "fails" as well. The code generation itself is done without errors, but the request isn't formed correctly.

Swagger-codegen version

2.4.9

Swagger declaration file content or url
parameters:
 - in: formData
 name: images
 description: Image files for the post
 type: array
 items:
 type: string
 format: binary
Command line used for generation

Java (okhttp-gson): java -jar swagger-codegen-cli.jar generate -DhideGenerationTimestamp=true -DartifactId="android-client" -DartifactVersion="0.1" -i openApi.yml -l java --library=okhttp-gson -o build/
Swift5: java -jar swagger-codegen-cli.jar generate -i openApi.yml -l swift5 -o build/

Steps to reproduce
  1. Create a Swagger 2.0 document with a POST endpoint and the parameter provided above.
  2. Run the code generation with one of the commands from above.
  3. Take a look at the generated methods for the upload and/or try to send a file (a simple [mocked] backend should suffice).
Related issues/PRs

OAI/OpenAPI-Specification#254
swagger-api/swagger-codegen-generators#150

PR: #9840

Suggest a fix/enhancement

The codegen templates for Java with okhttp-gson and Swift5 (Alamofire) should interpret arrays with binary strings as file parameters. Like swagger-codegen for the normal Java client does.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /