YAML anchors and refs in DW config

290 views
Skip to first unread message

Tommy Becker

unread,
Jun 19, 2017, 10:30:57 AM6/19/17
to dropwizard-user
Does anyone have an example of YAML anchors/references actually working in a Dropwizard app? We have a couple of config values that are duplicated in a few places in the config, and I would very much like to use anchors/refs to deduplicate it. From what little I have been able to find it seems like it should work, but for the life of me I can't get it to.  I've annotated with @JsonIdentityInfo, and Jackson seems to recognize the anchors in that it strips them out of the config, but the references are not replaced properly, "*foo" gets replaced by simply "foo" for example. Any ideas?

Christopher Currie

unread,
Jun 19, 2017, 12:44:11 PM6/19/17
to dropwiz...@googlegroups.com
You might try isolating what you're trying to do into a test case that uses Jackson and its YAML parser directly, without Dropwizard in the way, and if you can reproduce it there, asking on the Jackson User list: https://groups.google.com/d/forum/jackson-user

HTH,
Christopher

On Mon, Jun 19, 2017 at 7:30 AM, Tommy Becker <twbe...@gmail.com> wrote:
Does anyone have an example of YAML anchors/references actually working in a Dropwizard app? We have a couple of config values that are duplicated in a few places in the config, and I would very much like to use anchors/refs to deduplicate it. From what little I have been able to find it seems like it should work, but for the life of me I can't get it to.  I've annotated with @JsonIdentityInfo, and Jackson seems to recognize the anchors in that it strips them out of the config, but the references are not replaced properly, "*foo" gets replaced by simply "foo" for example. Any ideas?

--
You received this message because you are subscribed to the Google Groups "dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tatu Saloranta

unread,
Jun 20, 2017, 1:54:18 AM6/20/17
to dropwiz...@googlegroups.com
Anchors are supported to some degree, but only for cases where Object Id handling is explicitly specified for value type with `@JsonIdentityInfo`, and I don't think this is done for most config values for dropwizard configuration.
Problem here is that enabling identity also requires specification of an id property for values; if such a property exists, fine, if not, one would need to be added.

General purpose transparent resolution of anchors/references is not supported by Jackson YAML module.
You could probably implement a pre-processing step to do expansion first, then feeding resulting "flattened" input back to dropwizard.

-+ Tatu +-


On Mon, Jun 19, 2017 at 7:30 AM, Tommy Becker <twbe...@gmail.com> wrote:
Does anyone have an example of YAML anchors/references actually working in a Dropwizard app? We have a couple of config values that are duplicated in a few places in the config, and I would very much like to use anchors/refs to deduplicate it. From what little I have been able to find it seems like it should work, but for the life of me I can't get it to.  I've annotated with @JsonIdentityInfo, and Jackson seems to recognize the anchors in that it strips them out of the config, but the references are not replaced properly, "*foo" gets replaced by simply "foo" for example. Any ideas?

--
Reply all
Reply to author
Forward
0 new messages