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.

YAML Anchors / References

See original GitHub issue

Hi there, first of all thanks heaps for your awesome work with Jackson.

I am trying to get a concise configuration out of a yaml file, but I am pretty stuck at the moment.

I have followed many issues and still did not managed to get it working using only @JsonIdentityInfo By the this tests it should be as simple as annotating Environment class with @JsonIdentityInfo(generator = ObjectIdGenerators.StringIdGenerator.class) but that also did not work.

After reading this issue i thought it could be the scope, so I have annotated the environment and bundle1 properties adding the main Configuration class as scope but that also yield not success. Is this possible today, if it is how can it be achieved, and if not what do you recommend?

As the issue 266 suggests, I should write my own DeserializationContext, and figure out a way to find the references. But “you” --I believe it is you-- recommended this before.

Which of these two should I follow if there is no simple way to get it working with the current 2.9.6 version?

Trying to debug I did not see any calls to bindItem which means that SimpleObjectIdResolver._items are always null, even though I can see the references being set what would trigger that line to be called? Please keep in mind that I don’t claim to know anything about jackson, that was what I could gather from trying to debug it.

name: "dropwizard-app"

environment: &environment 
    profile: "dev"
    provider: "aws"
    segment: "segment"
    security-context: "test"
    region: "us-east-1"

bundle-1: &bundle1
    environment: *environment
    path: "x/y/z"

bundle-2:
    # property-config-1: (optional)
    endpoint: "https://my-service-1"
    bundle-1-configuration: *bundle1

PS. Like the tests I have also tried the anchoring as a prefix, but it seems that the library have no issues finding both ways.

Thanks again.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:14
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
cowtowncodercommented, Feb 14, 2019

Created 2 new issues to possibly address this:

  • #120: possibly support full resolution just for JsonNode (“Tree Model”)
  • #121: investigate if SnakeYAML exposes model in which anchors, references, are automatically expanded, and if so, could be used
1reaction
nkieselcommented, Nov 28, 2019

YAML only allows backward references: spec says “It is an error for an alias node to use an anchor that does not previously occur in the document.” (“alias” node here is the usage of a reference, and “anchor” is it’s definition). However, it is allowed to redefine anchors. Thus as I see it, a single pass could resolve all the references.

Read more comments on GitHub >

github_iconTop Results From Across the Web

YAML - Anchors, References, Extend - daemonl
The & defines and names an anchor, and the * uses it. Which probably seems more useful than it is - you can...
Read more >
YAML anchors | Bitbucket Cloud - Atlassian Support
When using Bitbucket Pipelines, YAML anchors reduce effort and make updating in bulk, easier.
Read more >
Advanced YAML syntax cheatsheet - Educative.io
Anchors and Aliases are YAML constructions that allow you to reduce repeat syntax and extend existing data nodes. You can place Anchors (...
Read more >
YAML Examples for Anchors, Aliases, and Overrides - Linode
This guide gives you examples for using YAML anchors, aliases, ... take you beyond the basics covered in the A YAML Syntax Reference...
Read more >
Don't Repeat Yourself with Anchors, Aliases and Extensions in ...
YAML anchors and aliases let you reference and use the same data multiple times within a single YAML document. You can use them...
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