.
|- tools
| |- bundler.js // contains use of oasNormalize
|- api
|- my-api.yaml
|- paths
|- path.yaml
If my-api.yaml contains a $ref: "./paths/path.yaml" it will fail with
node ./tools/bundler.js ./api/my-api.yaml
But will succeed with
cd ./api
node ../tools/bundler.js ./my-api.yaml
A $ref should be evaluated relative to the currently open file.
My bundler.js code:
import OASNormalize from "oas-normalize";
// if I make next line load ./api/my-openapi.yaml then it will fail to load references
const oas = new OASNormalize("./my-openapi.yaml", {
enablePaths: true,
});
oas
.validate()
.then(() => oas.convert())
.then((definition) => {
console.log(definition);
})
.catch((err) => {
console.error(err);
});