-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Labels
Description
Currently, openapi-format dereferences the OpenAPI documents to do its formatting, sorting, ... and write a dereferenced result.
Investigate the option to leverage: https://www.npmjs.com/package/json-refs to format the OpenAPI documents and update the $ref values in different files.
const jsonRefs = require('json-refs');
const json = {
"foo": {
"$ref": "#/bar"
},
"bar": {
"baz": "qux"
}
};
const options = {
filter: ['relative', 'remote'],
loaderOptions: {
processContent: (res, callback) => callback(undefined, res.text)
}
};
jsonRefs.resolveRefs(json, options).then(
(results) => {
// make changes to the resolved object
results.resolved.bar.baz = "newValue";
// write the changes to the $ref locations
jsonRefs.updateRefs(results.refs, results.resolved).then(
(updated) => console.log(updated),
(err) => console.log(err)
);
},
(err) => console.log(err)
);rngtng and taisph