Skip to content

Not able to execute request for multipart/form-data #6250

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

Closed
vinaylondhe-highspot opened this issue Jul 21, 2020 · 6 comments · Fixed by #6518
Closed

Not able to execute request for multipart/form-data #6250

vinaylondhe-highspot opened this issue Jul 21, 2020 · 6 comments · Fixed by #6518

Comments

@vinaylondhe-highspot
Copy link

vinaylondhe-highspot commented Jul 21, 2020

Q&A (please complete the following information)

  • OS: macOS
  • Browser: chrome
  • Method of installation: dist
  • Swagger-UI version: 3.29.0
  • Swagger/OpenAPI version: OpenAPI 3.0

Describe the bug you're encountering

When multipart/form-data is selected as the Content-Type and a file is selected to be uploaded, nothing happens after clicking on Execute. The Execute button does not work at all.

To reproduce...

Steps to reproduce the behavior:

  1. Go to swagger ui page
  2. Select multipart/form-data as the Content-Type in the request body
  3. Upload file to be sent in the request
  4. Click on 'Execute'

Expected behavior

The request should be made to the appropriate endpoint. Instead, the request is not made at all

@hkosova
Copy link
Contributor

hkosova commented Jul 22, 2020

@vinaylondhe-highspot can you provide an OpenAPI definition to reproduce the issue?

@vinaylondhe-highspot
Copy link
Author

@hkosova So I can confirm that I am able to execute the request just fine when I have something like

   requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - filename
              properties:
                filename:
                  type: string
                  description: The file
                  format: binary

But when I have something like the below definition (basically when you can send either of multipart/form-data or application/json content for the same endpoint), I can confirm that the Execute button does not work

requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  description: The file
                  format: binary
          application/json:
            schema:
              $ref: '#/components/schemas/item-spec'

And I want to use this version because of this bug fix #6223

@vinaylondhe-highspot
Copy link
Author

And this is happening for the versions 3.29.0 and 3.30.0.

@tim-lai
Copy link
Contributor

tim-lai commented Jul 23, 2020

I believe that this issue has the same root cause as #6201. My comment

@tim-lai
Copy link
Contributor

tim-lai commented Jul 23, 2020

@vinaylondhe-highspot Imo, it would be much better api design to have separate api endpoints for multipart/form-data. Then you would know to explicitly expect and handle various files, permissions, and security.

@vinaylondhe-highspot
Copy link
Author

@tim-lai I agree that its a much better API design to have separate api endpoints. Unfortunately, I cannot do that right now since it will break our existing clients

tim-lai added a commit that referenced this issue Oct 14, 2020
* When the media-type is changed, there is a new `onChangeMediaType` method to handle actions.
* If target schema properties key/value pairs does NOT equals current schema properties, clear the requestBodyValue, try-it-out request/response and validation params.
* If target schema properties key/value pairs DOES equals current schema properties, do not change or re-render schema properties
* oas3Selector `validateShallowRequired` now also validates required keys against target media-type

Fixes #6201, #6250, #6476
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants