thim81 / thim81/openapi-format
Keep $ref dereference when writing the update files
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 177
- Forks
- 29
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 1
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)
);
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing openapi-format's current dereference, formatting, and file-writing flow, then read the linked json-refs example for resolveRefs and updateRefs. Done should mean formatted OpenAPI documents preserve their $ref values and propagate changes back to the referenced files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100