Skip to content

Allow YAML anchors #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 16, 2018
Merged

Allow YAML anchors #108

merged 4 commits into from
Sep 16, 2018

Conversation

ehmicky
Copy link
Contributor

@ehmicky ehmicky commented Apr 13, 2018

YAML anchors like &anchor and *anchor on objects or arrays throw the following error:

.../node_modules/recursive-iterator/dist/recursive-iterator.js:129
	                                throw new Error("Circular reference");
	                                ^

Error: Circular reference
    at RecursiveIterator.next (.../node_modules/recursive-iterator/dist/recursive-iterator.js:129:40)
    at seekWrong (.../node_modules/swagger-jsdoc/lib/swagger-helpers.js:230:64)
    at .../node_modules/swagger-jsdoc/lib/swagger-helpers.js:259:5
    at Array.forEach (<anonymous>)
    at Object.findDeprecated (.../node_modules/swagger-jsdoc/lib/swagger-helpers.js:257:11)
    at module.exports (.../node_modules/swagger-jsdoc/lib/index.js:108:35)
    at createSpecification (.../node_modules/swagger-jsdoc/bin/swagger-jsdoc.js:44:34)
    at .../node_modules/swagger-jsdoc/bin/swagger-jsdoc.js:191:5
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:525:3)
.../node_modules/recursive-iterator/dist/recursive-iterator.js:129

The reason is when using YAML anchors, references are created. However there seems to be a bug in recursive-iterator where if two siblings are the same reference, this still throws a Circular reference error.

I fixed it by allowing circular references in recursive-iterator.

@kalinchernev
Copy link
Contributor

@ehmicky I merged #109 few minutes ago and there won't be anchors in the specification object any more. Thus, I think there won't be any more cases of circular dependencies, right? (if users don't overuse the swagger $refs :)

@ehmicky
Copy link
Contributor Author

ehmicky commented Jul 19, 2018

Correct me if I'm wrong but I think #109 was about YAML anchors when swagger-jsdoc serializes the JavaScript object to YAML. This is about references due to YAML anchors when swagger-jsdoc parses YAML to a JavaScript object, i.e. is probably still relevant.

@kalinchernev kalinchernev merged commit 24ed922 into Surnet:master Sep 16, 2018
@ehmicky ehmicky deleted the feature/yaml_anchors branch September 16, 2018 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants