Skip to content

How to use SwaggerClient in web worker #2008

@tmkasun

Description

@tmkasun

I'm getting

browser.js:1 Uncaught ReferenceError: window is not defined

This exception is coming from
swagger-client -> HTTP -> form-data-monkey-patch -> isomorphic-form-data)

Exception when trying to use SwaggerClient in a web worker. I did a little bit of a search and found that there is an issue created in isomorphic-form-data repo asking for a solution.

I tried setting outputglobalobject in webpack output also, But that didn't work.

Q&A (please complete the following information)

  • OS: macOS
  • Environment: Chrome Version 89.0.4389.90
  • Method of installation: npm
  • Swagger-Client version: 3.12.0
  • Swagger/OpenAPI version: OpenAPI 3.0.1

Content & configuration

Swagger/OpenAPI definition:

Link to definition

Swagger-Client usage:

import SwaggerClient from 'swagger-client';

SwaggerClient.resolve({
    url: '/api/am/publisher/v2/swagger.yaml',
    requestInterceptor: (request) => {
        request.headers.Accept = 'text/yaml';
    },
}).then((spec) => {
    self.postMessage(spec);
});

Screenshots

image

How can we help?

Can you please help me in using the SwaggerClient in the work environment? Is SwaggerClient support it or am I doing anything wrong here?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions