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

Editor cannot send request with file #599

Closed
hantuzun opened this issue Aug 24, 2015 · 7 comments
Closed

Editor cannot send request with file #599

hantuzun opened this issue Aug 24, 2015 · 7 comments

Comments

@hantuzun
Copy link

Hi,

We have an endpoint with the following parameters:

      parameters:
        - name: upload
          in: formData
          required: true
          type: file

I wanted to try the endpoint using the editor. I choose a file on the editor, set the header and then hit the "send request".

However, the editor doesn't send the file content. The following is the body is being send by the editor:

(upload: actions.csv)

Whereas a proper request should have such a body:

(--------------------------a1c5ec12084324b4 
Content-Disposition: form-data; name="upload"; filename="actions.csv" 
Content-Type: application/octet-stream 
 "230", "969",  4 "90",  "1101", 4 "276", "234",  5 "325", "168",  3 "15",  "754",  5 "324", "298",  5 "73",  "48",   2 "232", "315",  5 "328", "98",   4 "128", "588",  5 
 --------------------------a1c5ec12084324b4--)

Could you confirm that this issue about the swagger-editor?

@mohsen1
Copy link
Contributor

mohsen1 commented Aug 24, 2015

For now, file only in body is supported.

@webron
Copy link
Contributor

webron commented Aug 25, 2015

@mohsen1 - as the spec defines it, file is only supported with formData, not body. This is a bug.

@hantuzun
Copy link
Author

Yes @webron, I was about to point this out.

@mohsen1
Copy link
Contributor

mohsen1 commented Sep 22, 2015

@webron is this the only way to have file parameters in Swagger?

@mohsen1 mohsen1 modified the milestones: 2.9.9, Backlog Sep 22, 2015
@webron
Copy link
Contributor

webron commented Sep 23, 2015

Of type file? Yes.

@saharj
Copy link
Contributor

saharj commented Mar 10, 2016

Moving it to next milestone.

@suyuan1203
Copy link

suyuan1203 commented Dec 12, 2016

this bug is still not fixed because the code calls $.ajax with Content-Type as 'application/json'.

scripts/controllers/tryoperation.js

makeCall function

$.ajax({
      url: $scope.generateUrl(),
      type: $scope.operationName,
      headers: _.omit($scope.getHeaders(), omitHeaders),
      data: $scope.getRequestBody(),
      contentType: $scope.contentType,
      processData: false
    })

the contentType property should be set as false.

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

No branches or pull requests

5 participants