Skip to content

Commit

Permalink
fix(playground): fix importing definition from URL (#4318)
Browse files Browse the repository at this point in the history
* fix: issue with missing imported file contents

* feat: use file interface

---------

Co-authored-by: Vazha Omanashvili <[email protected]>
  • Loading branch information
rainum and Vazha Omanashvili authored Aug 14, 2024
1 parent fbc0fec commit 3d32525
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/apidom-playground/src/playground/apidom.worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
readFile,
resolveApiDOM as resolveApiDOMReferences,
dereferenceApiDOM as derefereceApiDOMReferences,
File,
} from '@swagger-api/apidom-reference';

const parser = new ApiDOMParser()
Expand All @@ -44,9 +45,9 @@ const service = {
return JSON.stringify(refract, undefined, 2);
},

async readFile(url) {
const buffer = await readFile(url, {});
return buffer.toString();
async readFile(uri) {
const buffer = await readFile(uri, {});
return new File({ uri, data: buffer }).toString();
},

async resolveApiDOM(apiDOM, { source, mediaType, baseURI }) {
Expand Down

0 comments on commit 3d32525

Please sign in to comment.