Failed to parse OpenAPI file
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.yamlis 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
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).
Did you find a solution for this?
Did you find a solution for this?
Unfortunately, no.
You have to run this on http-server when you are running locally. Use the following https://www.npmjs.com/package/http-server
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.