.resolved not showing resolved reference but .refs shows properly resolved???
terencechow opened this issue · comments
terencechow commented
Using resolveRefs
I am not getting any errors but the result is not resolved. What am I doing wrong? I see that the refs have the proper values, but the resolved result doesn't show that.
What am I doing wrong?
Folder structure:
|-index.yaml
|-paths
|-index.yaml
|-accounts.yaml
index.yaml:
paths:
$ref: ./paths/index.yaml
paths/index.yaml:
$ref: ./accounts.yaml
And paths/accounts.yaml:
/accounts:
get:
...
Basically I expect to see
paths:
/accounts
get:
...
But I see:
paths:
$ref: ./accounts.yaml
Here is my code:
const swaggerYaml = yaml.safeLoad(fs.readFileSync(`${swaggerRootDir}/index.yaml`, 'utf8').toString())
var options = {
filter: ['relative'],
location: `${swaggerRootDir}/index.yaml`,
loaderOptions: {
processContent: function (res, callback) {
callback(yaml.safeLoad(res.text))
}
}
}
resolveRefs(swaggerYaml, options).then(function (results) {
console.log(yaml.dump(results.refs)) # --> prints out proper object at 'value'
console.log(yaml.dump(results.resolved)) # --> prints out $ref: './accounts.yaml'
})
.catch((err) => {
console.log('ERROR', err)
})
terencechow commented
Looks like I had an error in my yaml.
Jeremy Whitlock commented
Don't scare me like that. (joke)