question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

not able to parse anchor variable reference

See original GitHub issue

Hi,

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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
dervuscommented, Oct 18, 2016

JS-YAML registers anchors only for non-empty nodes. I’ll check if it conforms the spec or not.

0reactions
rlidwkacommented, Dec 29, 2020
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found