Comments (6)
well, checkout the QuickStart section,
you need to create an HTML with the following content
<!doctype html>
<html>
<head>
<script src="https://unpkg.com/rapipdf/dist/rapipdf-min.js"></script>
</head>
<body>
<rapi-pdf
spec-url = "path/of/your/spec/file"
button-bg = "#b44646"
> </rapi-pdf>
</body>
</html>
place this html, on a server from where you can access your spec.
the other option would be to upload your spec to a public location such as github, and try to use that for generation
from rapipdf.
I used the quickstart section as a guide.
if I have
<!doctype html>
<html>
<head>
<script src="https://unpkg.com/rapipdf/dist/rapipdf-min.js"></script>
</head>
<body>
<rapi-pdf
spec-url = "file:///home/me/docs/openapi.yml"
button-bg = "#b44646"
> </rapi-pdf>
</body>
</html>
It doesn't work. Nor does
spec-url = "/home/me/docs/openapi.yml"
The page is displayed with a button. Clicking the button does nothing. Error in console is
rapipdf-min.js:8673 Fetch API cannot load file:///home/akitson/Projects/Synapse/api-logon-service/docs/openapi.yml. URL scheme must be "http" or "https" for CORS request.
Changing the spec-url to https://docs.ops.zinc.systems/authentication.yml (only I can see this url) gives
Access to fetch at 'https://docs.ops.zinc.systems/authentication.yml' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
So, your fetch mechanism doesn't recognise a local file. That will make the app difficult to use in a build chain.
CORS is more problematic and is possibly due to the browser, rather than your code. Do you have a way of running this locally in a script? I don't see any tests so cannot determine how to run it locally.
from rapipdf.
can you try a relative url
have the html
and spec
file in the same location and specify spec-url="./openapi.yml"
something like this
<!doctype html>
<html>
<head>
<script src="https://unpkg.com/rapipdf/dist/rapipdf-min.js"></script>
</head>
<body>
<rapi-pdf spec-url = "./openapi.yml"> </rapi-pdf>
</body>
</html>
from rapipdf.
Same issue using relative path:
Fetch API cannot load file:///home/akitson/Projects/Misc/architecture/openapi.yml. URL scheme must be "http" or "https" for CORS request.
Uncaught (in promise) TypeError: Cannot read property 'paths' of undefined
So for a file path, it is still trying to do a CORS request
from rapipdf.
I disabled CORS in the browser as per https://alfilatov.com/posts/run-chrome-without-cors/ and still get the CORS error above. This perhaps suggest that CORS is being handled in the code rather than the browser.
from rapipdf.
I found a (not automated) way to generate docs, if your spec does not contain any sensitive data you can upload your file as a JSON bin on a site such as: https://www.npoint.io/
With your content uploaded and available through a public URL with properly-set CORS restrictions in response headers, the lib should work as expected. Hope it helps someone!
from rapipdf.
Related Issues (20)
- support for openapi v3.1 HOT 3
- Attribute pdf(-alternate)-color is not applied to toc HOT 1
- Using content to define serialization is not supported in query
- Tool randomly merges two words into one when having description. HOT 1
- anyOf does not work
- feat: add header
- Support images
- Tables aren't being formatted properly
- content application/json in header return error : rapipdf-min.js:33145 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'deprecated')
- Add images from description markdown to PDF
- when 2 operations have the same input schema definitions, the requests in the PDF output are not displayed HOT 3
- 中文乱码,如何解决? HOT 3
- Feature Request: Support for Webhooks (Callbacks)
- Support Dictionary<string, string>
- Add response headers
- Wrong PDF rendering with basic OpenAPI description HOT 2
- Applying the format value to the type?
- The markdown in parameters property description or in response schema property description is not convert to right html text.
- Hide Request types
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rapipdf.