Skip to content

Commit

Permalink
use RefParser to dereference JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
Oreoxmt committed Jul 10, 2022
1 parent 8df122b commit 47b4931
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/deref.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const fs = require("fs");
const $RefParser = require("@apidevtools/json-schema-ref-parser");

async function deref(readf, writef) {
const data = fs.readFileSync(readf, 'utf8');
const schema = await $RefParser.dereference(JSON.parse(data));
fs.writeFileSync(writef, JSON.stringify(schema, null, 2));
console.log("Wrote dereferenced schema to", writef);
}

module.exports = deref;

0 comments on commit 47b4931

Please sign in to comment.