0

I am trying to run up a small redoc server locally. I have created the swagger.json file. And it works fine when I place it in a hosted webserver and point to it in the index.html file as:

<redoc spec-url='https://:......../swagger.json'></redoc> 

What I need to do is run this locally. To get around the CORS problem, I've opted to host a web server locally on port 8000 and view it there. So in a folder, I place the index.html file and the swagger.json file. I run up the server using

$ python -m SimpleHTTPServer 8000

That works fine (I've tested it with a hello world index.html). Now with the proper html file, I am trying to reference the swagger file locally like this:

<redoc spec-url='file:./swagger.json'></redoc>

and Im'pretty sure it's finding the file (when it could not, it gave other errors), but the page shows this error:

Something went wrong... Cannot read property 'readFile' of undefined Stack trace Error: Cannot read property 'readFile' of undefined at t.BaseResolver. (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:37:13513) at Generator.next () at https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:37:11844 at new Promise () at r (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:37:11589) at t.BaseResolver.loadExternalRef (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:37:13295) at t.BaseResolver. (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:37:14025) at Generator.next () at https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:37:11844 at new Promise ()

ReDoc Version: 2.0.0-rc.53 Commit: 5c8524d

Is my approach valid? How can I get it to display the content correctly?

edit I just double clicked on the html file and opened it directly in the browser, and got the exact same error... Is this still a CORS thing - if using the server doesn't change the error???

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.