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

Use a local file for spec-url #2489

Closed
ma-ble opened this issue Feb 9, 2024 · 1 comment
Closed

Use a local file for spec-url #2489

ma-ble opened this issue Feb 9, 2024 · 1 comment

Comments

@ma-ble
Copy link

ma-ble commented Feb 9, 2024

I want to know if it is possible to use a local file for spec-url. In the documentation this scenario is managed as a valid use case.

Set spec-url to a relative path if the file is local, e.g. spec-url=my-api.yaml.

For testing I download the swagger.json from the example and store it in the same folder as the html file.

<body>
   <redoc spec-url='swagger.json'></redoc>
   <script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js"> </script>
 </body>`

My error message loading the file into my browser is.

Something went wrong...
process is not defined
Stack trace
ReferenceError: process is not defined
    at Object.resolve (https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:2:220797)
    at t.BaseResolver.resolveExternalRef (https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:2:30606)
    at t.BaseResolver.<anonymous> (https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:2:31505)
    at Generator.next (<anonymous>)
    at https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:2:29037
    at new Promise (<anonymous>)
    at r (https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:2:28782)
    at t.BaseResolver.resolveDocument (https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:2:31458)
    at https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:2:5170
    at Generator.next (<anonymous>)

ReDoc Version: 2.1.3
Commit: b2d8e0f

I have also found an issue where using local files was not supported due to security issues:
#149

@lornajane
Copy link
Contributor

@ma-ble Thanks for reaching out to us. You can use a local file, but you need to be serving it locally so that it is available on a localhost URL. It can be a relative URL if you're also serving the HTML page locally as well. You are correct that the advice in #149 will apply here.

I think this answers question, but feel free to let us know if you need anything else!

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

2 participants