-
Notifications
You must be signed in to change notification settings - Fork 762
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
SwaggerClient and data:url's #2381
Comments
i guess a update to node-fetch@3 would add support for dataurls |
Yes @jimmywarting is absolutely right. We need import fs from 'node:fs';
import util from 'node:util';
import fetch from 'node-fetch';
const data = fs.readFileSync('./petstore.json').toString('base64');
const dataURL = `data:application/json;base64,${data}`;
const response = await fetch(dataURL);
const jsonBody = await response.json();
console.dir(jsonBody); When #2414 and #2415 are processed this issue will autoresolve. |
+1 This would be a great add to allow a local load of a swagger file vs relying on a hosted version. Looking to use this solution where adding an extra HTTP fetch is not ideal. |
🎉 This issue has been resolved in version 3.21.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Hi folks!
I tried to handle data:url for spec instead and faced an exception.
The documentation said
var specUrl = 'http://petstore.swagger.io/v2/swagger.json'; // data urls are OK too 'data:application/json;base64,abc...'
but it does not work.
Example
throws
What is wrong here?
The text was updated successfully, but these errors were encountered: