Giter VIP home page Giter VIP logo

Comments (6)

mrin9 avatar mrin9 commented on May 18, 2024

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.

akzincsystems avatar akzincsystems commented on May 18, 2024

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.

mrin9 avatar mrin9 commented on May 18, 2024

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.

akzincsystems avatar akzincsystems commented on May 18, 2024

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.

akzincsystems avatar akzincsystems commented on May 18, 2024

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.

cfecherolle avatar cfecherolle commented on May 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.