swagger-js icon indicating copy to clipboard operation
swagger-js copied to clipboard

Could we get swagger-js client to deno?

Open xli opened this issue 3 years ago • 3 comments

Can't import swagger client in deno (https://deno.com) from current npm publish. Any chance to get swagger-js deploy to deno?

xli avatar Nov 30 '21 00:11 xli

@xli can you provide more information or investigate why swagger-js cannot be used with deno? I'm willing to collaborate with you on this, but need more info.

char0n avatar Dec 21 '21 10:12 char0n

There are some dependencies are not on deno if you tried to import from npm. For example, after launch deno console, execute: import client from "https://dev.jspm.io/swagger-client";

> import client from "https://dev.jspm.io/swagger-client";
Download https://dev.jspm.io/npm:cross-fetch@3/polyfill?dew
Uncaught TypeError: Import 'https://dev.jspm.io/npm:cross-fetch@3/polyfill?dew' failed, not found.
    at https://dev.jspm.io/npm:[email protected]/lib/http/index.dew.js:1:40
    at async <anonymous>:2:30

I think a better support is deploy swagger-js to deno (it supports deploy from github repo), and probably need figure out solution for dependencies that are not on deno.

xli avatar Dec 21 '21 18:12 xli

Right, so this looks like a problem with dependencies of swagger-client which we have no control over.

As far as I understand deno allows importing JavaScript from URLs. Part of our npm distribution is a UMD bundle that is completely standalone.

import SwaggerClient from 'https://unpkg.com/browse/[email protected]/dist/swagger-client.browser.js';

As long as deno supports CommonJS it should be able to process this import. The only thing that might prevent this is that we build this bundle against window object. If you download this file locally and replace window on line 10 with globalThis things should work. Please let me know if it works, and if yes, we'll release next version of the bundle to unpkg with globalThis object and it should allow you to use swagger-client in deno.

Cheers

char0n avatar Jan 14 '22 13:01 char0n