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

UI file responses not downloading #1196

Closed
hamx0r opened this issue Apr 22, 2015 · 4 comments
Closed

UI file responses not downloading #1196

hamx0r opened this issue Apr 22, 2015 · 4 comments
Milestone

Comments

@hamx0r
Copy link

hamx0r commented Apr 22, 2015

As of swagger-ui develop_2.0 branch commit d76a62c which included a fix for bug #374, there seems to be a bug preventing the\\Download block of code:

    // Download
    } else if (headers['Content-Disposition'].test(/attachment/) ||
               headers['content-disposition'].test(/attachment/) ||
               headers['Content-Description'].test(/File Transfer/) ||
               headers['content-description'].test(/File Transfer/)) {

Chrome's Developer Tools console shows Uncaught TypeError: Cannot read property 'test' of undefined in swagger-ui.js:21394 (above). The progress animation runs forever.

The Content-Disposition in my response is attachment; filename=file.zip and the response is a valid ZIP. The error suggest headers[] isn't being properly populated. The relevant parts of the Swagger Spec feeding the UI are (esp responses):

        "/flights/csv/{flight_id}": {
            "parameters": [{
                "required": true,
                "type": "string",
                "name": "flight_id",
                "in": "path"
            }],
            "get": {
                "tags": ["flights"],
                "summary": "\n        Return CSV of flights, one for each flight \"id\" (a CSV list of id's is acceptable)\n        ",
                "responses" : {
                    "200" : {
                        "description" : "CSV ZIP File",
                        "schema" : {
                            "type" : "file"
                        }
                    }, ...
                },
                "parameters": [{
                    "name": "flight_id",
                    "required": true,
                    "in": "path",
                    "type": "string",
                    "description": "CSV list of flight IDs"
                },
@ponelat
Copy link
Member

ponelat commented Apr 23, 2015

the fix looks to be in a pending PR #1122
@webron not sure on the protocol here with other PRs...

@darioDelTemple
Copy link

We are having a similar issue. In our case we want to download a .crt file. This is the response header:

Status Code: 200
Date: Wed, 29 Apr 2015 14:21:05 GMT
Server: servername
Etag: "e1e9bc2cf65550466fc3d1814a3d613de6ae210c"
Access-Control-Max-Age: 1728000
Content-Type: application/octet-stream
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Content-Disposition: attachment;filename="CA.crt"
Access-Control-Allow-Headers: *
Content-Length: 1306

Printing headers in swagger-ui.js, in the showStatus method shows:
headers: {"content-type":"application/octet-stream"}

Do you have an estimate when this fix will be included?

@fehguy
Copy link
Contributor

fehguy commented May 8, 2015

This should be fixed now, please reopen if you have any issues.

@Ankitsinghalatjolly
Copy link

This is not yet fixed.

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

6 participants