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

Download button opens new tab instead of downloading #1247

Closed
kgemmert-r7 opened this issue Apr 27, 2020 · 4 comments
Closed

Download button opens new tab instead of downloading #1247

kgemmert-r7 opened this issue Apr 27, 2020 · 4 comments

Comments

@kgemmert-r7
Copy link

kgemmert-r7 commented Apr 27, 2020

we have noticed an issue when moving to openApi 3.0 that the download button does not download but just opens the data in a new tab.

we are using openApi 3.0 and https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js for the build script.

when using the local redoc-cli client to build, the download works fine.

I can see the same happening in your redoc page when downloading the docs: http://redocly.github.io/redoc/

To re-create you can try our api docs
https://help.rapid7.com/insightAccount/en-us/api/v1/docs.html

The download works fine with docs using openApi 2.0
https://help.rapid7.com/insightappsec/en-us/api/v1/docs.html

@c3rajkaramchedu
Copy link

c3rajkaramchedu commented Apr 28, 2020

I had the same issue and I fixed it by doing the following. See https://c3.ai/covid-19-api-documentation/ for example (the page might ask you to accept some terms but these are COVID-19 public docs, so no harm in accepting and getting to the page, methinks.)

  • In your <a>...</a> tags, remove "https://" and simply use the relative path to the file that you are expecting to download. Something to do with browsers not liking the cross domain and hence preventing download and instead opening it in a tab.
  • Use the "download" parameter in the <a>...</a> like this: <a href="/folder/file.txt" download="file.txt">Download Txt file</a>

See our OpenApi spec to see how I did it. Hope it helps!

Raj

@kgemmert-r7
Copy link
Author

kgemmert-r7 commented Apr 28, 2020

Thanks Raj, I manually changed that in the page and that worked and finally downloaded.

<a target="_blank" download="insightAccount-api-v1.json" class="sc-tilXH jIdpVJ">Download</a>

Do you know how this gets set though? Is it done by the redoc build script and I need to change arguments?

UPDATE: I just realised that the download still works for a full URL when I add the download option to my <a>...</a> tags which I only been able to manually do because I don't know where this gets set.

<a target="_blank" download="" href="https://help.rapid7.com/insightAccount/en-us/api/v1/insightAccount-api-v1.json" class="sc-tilXH jIdpVJ">Download</a>

@c3rajkaramchedu
Copy link

c3rajkaramchedu commented Apr 28, 2020

Do you know how this gets set though? Is it done by the redoc build script and I need to change arguments?

I don't know that, and glad it worked for you. I'll keep digging when I have a moment and post here anything new I learned.

@kgemmert-r7
Copy link
Author

thank you for fixing so quickly @RomanHotsiy ! works like a treat :)

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

2 participants