not able to parse anchor variable reference
See original GitHub issueHi,
I m trying to parse a swagger.yaml with js-yaml. I have defined anchor variables and referenced them as below.
x-a127-config:
abc: &ABC
xyz: &xyz
x-a127-services:
abc: *abc
**cache-session: *xyz**
The parser throws exception at line *cache-session: xyz
error: unidentified alias “xyz” at line 28, column 22: cache-session: *xyz ^
Below is my code
var yaml = require('js-yaml');
var doc;
try {
doc = yaml.load(stream.readFileSync(inputFilePath, 'utf8')); //inputFilePath -- is path to my swagger.yaml file
} catch (e) {
console.log(e);
}
Is there any option that can be used while parsing, so that js-yaml will parse the references to anchor variables successfully?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Parse Predictable Patterns Using an Anchor | Sumo Logic Docs
Parse Predictable Patterns Using an Anchor. The parse operator (also called the parse anchor) parses strings according to specified start and stop anchors, ......
Read more >Anchor Parse & NRQL Variables: Parsing values from Log just ...
NRQL Variables is a new way to store computed row-wise values (e.g. round, concat, anchor parse, etc.) into variables which can be referenced...
Read more >Preserve YAML anchors across includes in CI configuration
I can understand not being able to include something that recursively includes, but not being able to parse an anchor that exists in...
Read more >Couldn't append variable with single quote to anchor tag's title
Now the problem is I am not able to append this variable as title for anchor tag. I have tried using escape, unescape,...
Read more >Variable not defined on Data Extension but able to print it in ...
For parsing values from a payload, you can't just reference values by name -- you'll need to parse them out. For example if...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
JS-YAML registers anchors only for non-empty nodes. I’ll check if it conforms the spec or not.
Fixed in https://github.com/nodeca/js-yaml/commit/e8cf6f6aa335c6c63d844b470240c9be661baa7f (currently in
dev
branch).