elements icon indicating copy to clipboard operation
elements copied to clipboard

Failed to parse OpenAPI file

Open shokme opened this issue 3 years ago • 1 comments

Context

Cannot read local openapi.yaml file from HTML implementation using apiDescriptionDocument

Current Behavior

The rendered html show the following text

Failed to parse OpenAPI file
Please make sure your OpenAPI file is valid and try again

Expected Behavior

Render the openapi.yml to an HTML document

Steps to Reproduce

  • index.html
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>Api Documentation</title>

    <script src="https://unpkg.com/@stoplight/elements/web-components.min.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/@stoplight/elements/styles.min.css">
</head>
<body>
<elements-api apiDescriptionDocument="openapi.yaml" />
</body>
</html>
  • the openapi.yaml is the one from the demo website
  • open the index.html in your browser

Environment

  • Version used: unpkg
  • Environment name and version: Firefox 96.0
  • Operating System and version: Desktop Linux

shokme avatar Jun 29 '22 13:06 shokme

I also tried with apiDescriptionUrl instead of apiDescriptionDocument but the result is almost the same

Document could not be loaded
The API description document could not be fetched. This could indicate connectivity problems, or issues with the server hosting the spec.

Do I have to serve the index.html over an nginx server? (in that case with apiDescriptionUrl it works).

shokme avatar Jun 29 '22 13:06 shokme

Did you find a solution for this?

KavishPeiris1 avatar Sep 21 '22 15:09 KavishPeiris1

Did you find a solution for this?

Unfortunately, no.

shokme avatar Sep 24 '22 11:09 shokme

You have to run this on http-server when you are running locally. Use the following https://www.npmjs.com/package/http-server

KavishPeiris1 avatar Sep 28 '22 06:09 KavishPeiris1

I wanted to have something as simple as an html file, as our openapi is used internally. But this is ok we found another solution.

Thank you for your suggestion.

shokme avatar Sep 28 '22 11:09 shokme