Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could we get swagger-js client to deno? #2355

Open
xli opened this issue Nov 30, 2021 · 3 comments
Open

Could we get swagger-js client to deno? #2355

xli opened this issue Nov 30, 2021 · 3 comments
Assignees

Comments

@xli
Copy link

xli commented Nov 30, 2021

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

@char0n char0n self-assigned this Dec 21, 2021
@char0n
Copy link
Member

char0n commented Dec 21, 2021

@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.

@xli
Copy link
Author

xli commented Dec 21, 2021

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.

@char0n
Copy link
Member

char0n commented Jan 14, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants