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

Not able to decode multipart response #5293

Open
SachidanandAlle opened this issue Apr 10, 2019 · 6 comments
Open

Not able to decode multipart response #5293

SachidanandAlle opened this issue Apr 10, 2019 · 6 comments

Comments

@SachidanandAlle
Copy link

Q&A (please complete the following information)

  • OS: Windows
  • Browser: Chrome
  • Version: 73.
  • Method of installation: npm
  • Swagger-UI version: Latest
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Fails to decode the response when it is of multipart type.

Example Swagger/OpenAPI definition:

# your YAML here
  /xyz:
    post:
      parameters:
        - in: query
          name: q
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                upfile:
                  type: string
                  format: binary
                params:
                  type: string
      responses:
        '200':
          description: OK
          content:
            multipart/form-data:
              schema:
                type: object
                properties:
                  points:
                    type: string
                  file:
                    type: string
                    format: binary
              encoding:
                points:
                  contentType: text/plain
                file:
                  contentType: application/octet-stream

Describe the bug you're encountering

When the UI receives the response from the server where the response has multipart body, the UI doesn't decode the message and displays the result accordingly.

Currently it shows the following error and tries to display everything as text (even the binary junk characters) and the multipart data is not split into corresponding part files.

Response body
Unrecognized response type; displaying content as text.

--29c81d996c8947829f47f91a3c36aa4f
Content-Disposition: form-data; name="points"

[1,2,3,4,5]
--29c81d996c8947829f47f91a3c36aa4f
Content-Disposition: form-data; name="file"; filename="tmp1e95kj4w.nii.gz"
Content-Type: application/octet-stream

�����8�\��tmp1e95kj4w.nii��$��V��0?� �� 7������~���0��8u���JI))�ʔV�8���T�[Kս�̙�����G������Ͽ������������w���������������?����5����o���5�x������/O���_���?��ϟ���?}

Expected behavior

  1. binary data part as downloadable link
  2. text/plain data part on UI screen
@GorkaGut
Copy link

GorkaGut commented Jul 7, 2020

Hi SachidanandAlle, did you get an answer on this? I'm having exactly the same issue.
In fact, if I create the server stubs from the editor, they are creating a single part with all the content included as text, rather than a multipart response

@SachidanandAlle
Copy link
Author

No.. as a workaround (to unblock), I had to support additional flag at my server side to send/download binary or text/json only data in the response. Basically you will trigger copy of requests for each form type expected in the response. (Not a good idea)

It shall be great if Swagger UI can do parse the multi-response object and support different schema for each type.

@GorkaGut
Copy link

GorkaGut commented Jul 7, 2020

Thanks for you quick answer SachidanandAlle, yes it's a pitty, and it's strange that the Swagger UI and codegen is not able yet to handle these kind of responses.

@nikhilkumarenr
Copy link

Much needed feature as API client.

@hedi-sellami-shift
Copy link

Hi! Happy to finally find people who have the same issue :D
Any news concerning this issue? Any workaround that we can use to display a file alongside a textbox?

@eukaryoteman
Copy link

Hi! Any updates on this issue?

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

5 participants