Skip to content

Specify URI of apidom.worker.js in fully standalone mode? #5678

@hms5232

Description

@hms5232

Before v5, I use simple HTML to embed swagger editor and it works well. Now editor is v5, a new architecture is used, and I notice that there is a new file, apidom.worker.js.

Current HTML like:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <meta
    name="description"
    content="SwaggerEditor"
  />
  <title>SwaggerEditor</title>
  <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/swagger-editor.css" />
</head>
<body>
  <div id="swagger-editor"></div>
  <script src="https://unpkg.com/react@18/umd/react.production.min.js" crossorigin></script>
  <script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js" crossorigin></script>
  <script src="https://unpkg.com/[email protected]/dist/umd/swagger-editor.js"></script>
  <script>
    const props = {
      url: 'https://raw.githubusercontent.com/asyncapi/spec/v2.2.0/examples/streetlights-kafka.yml',
    };
    const element = React.createElement(SwaggerEditor, props);
    const domContainer = document.querySelector('#swagger-editor');

    ReactDOM.render(element, domContainer);
  </script>
</body>
</html>

Although the worker is not loaded, the editor can still work. The 404 request for /apidom.worker.js is not a big deal, but I still try to fix it.

I am not familiar with React, after reading the document, I still don't know how to change the URI of apidom.worker.js in standalone HTML.

const props = {
  url: 'https://raw.githubusercontent.com/asyncapi/spec/v2.2.0/examples/streetlights-kafka.yml',
  apidom_worker: 'https://unpkg.com/[email protected]/dist/umd/apidom.worker.js', // a way to specify the URI of `apidom.worker.js` like this?
};
const element = React.createElement(SwaggerEditor, props);
const domContainer = document.querySelector('#swagger-editor');

ReactDOM.render(element, domContainer);

Are there any ways to specify the URI of apidom.worker.js in standalone HTML?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions