-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Can't fetch local file #149
Comments
The reason is that the lib I use (json-schema-ref-parser) doesn't support I will fix this but this is not on the next-to-do queue coz this can be workarounded by simply running webserver |
@RomanGotsiy thanks for the quick reply! got it |
@RomanGotsiy Can you tell me how it can be worked around ? Sorry for asking this but i am new to this !! @yspotts How else did you mention your json file ? |
@vishesh1king just serve your spec and html page via any http-server (e.g. |
Got it thanks ... This is my main.json file: |
@vishesh1king your json file is not in OpenAPI (fka Swagger) format. ReDoc is OpenAPI/Swagger-generated API Reference Documentation. It works only with OpenAPI specs |
Ohh, I get it now !!! Thanks ... |
ReDoc demo spec in If you are not familiar with OpenAPI you can start from template spec (direct link). You should also check series of tutorials by API Handyman: http://apihandyman.io/writing-openapi-swagger-specification-tutorial-part-1-introduction/ |
workaround to have a web server will not work if one needs to send a static html/js documentation to a person that only has a browser ... |
Here is what worked for me.
|
@hmasila the reporter clearly stated that the "http://" works for him (and for others too). This ticket is about "file://" protocol support. |
@nthx I came across this thread when I was working with a local json file. It took me a while to pass it to the redoc tag as http. That is why I wrote my comment. To help any other person who might be in the same situation. |
Same issue here. Fred |
Hi guys, any news on this merge? I'm one of those people that doesn't want to/have time to set up a local server just to add a local file ref. |
I used json-schema-ref-parser recently and it works fine with local refs, even without the "file://" url prefix. However json-schema-ref-parser.Bundle() is not perfect from resolving remote $refs for swagger, from a documentation point of view. But at least it shoudl work on local refs. |
I have investigated this issue and it seems loading local swagger spec is impossible without running web-server due to same-origin policy and security reasons. I found other projects have the same issue not resolved, e.g.: https://threejs.org/docs/#manual/introduction/How-to-run-thing-locally.
I absolutely understand the use case though. There are two possible solutions to this use case:
If anyone though does know how to load local swagger spec, let me know! I'm not closing this issue until F.A.Q. is created and this is included there. |
This would be another argument for rolling redocup into v2.0 as a cli feature. Then the FAQ can read:
Or something. :) |
Hi folks, this would be a very useful feature indeed. Spectacle features this static generation. I'm not sure how it works in detail but maybe it'd be worth checking it out. I think they generate the html on the fly. I'm not familiar enough with ReDoc to know how much this approach is applicable |
|
@RomanGotsiy how to bundle spec using <link href="./static/fonts.css" rel="stylesheet" /> <!-- 404 -->
<script src="./static/redoc.standalone.js"> </script> <!-- 404 -->
<script>
Redoc.init('./scheme/methods.yaml', { // 404
theme: {
noAutoAuth: true,
requiredPropsFirst: true,
breakpoints: {
medium: 2
}
}
}, document.getElementById('container'))
</script> |
These problems for development environment were solved by {
"scripts": {
"start": "serve"
},
"dependencies": {
"redoc": "^2.0.0-alpha.38",
"serve": "^10.0.0"
}
} But how to build these files into one file — that's a problem! |
From redoc-cli help:
Use
or
For template use |
passing the local spec_file path to the redoc docker container is also a really convenient route (if you have docker installed)
source https://hub.docker.com/r/redocly/redoc ^ for future viewers |
I just found a neat little web server that runs in your browser. It can easily point to a local folder and serve up your http file with redoc standalone with a reference to a local swagger file: |
how to access multi ple local files ? |
@harsh4870 This repo would help you: https://github.com/volbrene/redoc |
My apologies if this is spelled out somewhere -- I looked through the issues.
I can't seem to direct ReDoc to load my OpenAPI spec from the local filesystem -- only via http. I have tried the following:
in addition to other permutations. However, they all result in this error:
Unable to resolve $ref pointer "file:///<pathname to my spec file>"
Is there any way to have ReDoc load the spec locally?
The text was updated successfully, but these errors were encountered: