You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The tag name of an embedded resource is inferred from the @XmlRoot annotation (xml_root_name in YAML, xml-root-name in XML) coming from the Serializer configuration.
Accordingly, I would have expected the serializer to produce a resource element with excluded visitor id and two links, something like:
Instead I received a result element with (not excluded) visitor id. The two links however are present, indicating that the configuration file is not skipped.
Using annotations instead of a configuration file works and would be a potential solution, yet unacceptable in my project.
This situation puzzled me somewhat, so I went bughunting, and found that the Hatoas XML-, YAML- and annotation drivers are only concerned with Hateoas specific elements (a Good Thing™) and the JMS drivers manage the rest of the configuration reading.
Since the JMS drivers, XmlDriver included, all have xml-root-name support, yet only the Annotation seemed to be functioning, the digging continued: it turns out the DefaultDriverFactory produces only an AnnotationDriver by default, unless metadata directories are provided.
The underlying problem seems to be that the Hateoas builder does not communicate to the JMS builder that a configuration directory was provided.
I managed to work around the problem (while keeping my precious xml config) by pre-configuring the SerializerBuilder:
Having this working, I quickly found that in order to use expressions from within the xml configuration, I also needed to setExpressionEvaluator.
It's all working now, but configuring it all becomes a bit awkward:
It seems like relatively easy to fix, I'll try to get a PR in somewhere this week.
TL;DR
HATEOAS builder does not add the MetadataDir nor Expression context variables to the JMS driver, leading to XML and YAML config mostly not working as expected.
The text was updated successfully, but these errors were encountered:
Ah, apologies for the confusion! The issue isn't about namespaces per se, it's just that xml-root-name, xml-root-prefix and xml-root-namespace don't work (out of the box) when configured in a xml configuration file. I've removed the namespace detail from the initial post, as it's essentially unrelated to the issue: when I configure xml-root-name="resource", the element I end up with is also a <result>.
In the "real" version, the account:resource has a proper namespace applied, although probably implemented in a sub-optimal way.
Hey all,
This library looks like a great time saver! However it seems like the xml configuration does not work as advertised out of the box.
I made this xml configuration for my
AccountOverview
class:And the HatoasBuilder is (or, was) configured as follows:
According to the readme:
Accordingly, I would have expected the serializer to produce a
resource
element with excluded visitor id and two links, something like:Instead I received a
result
element with (not excluded) visitor id. The two links however are present, indicating that the configuration file is not skipped.Solution
Using annotations instead of a configuration file works and would be a potential solution, yet unacceptable in my project.
This situation puzzled me somewhat, so I went bughunting, and found that the Hatoas XML-, YAML- and annotation drivers are only concerned with Hateoas specific elements (a Good Thing™) and the JMS drivers manage the rest of the configuration reading.
Since the JMS drivers, XmlDriver included, all have xml-root-name support, yet only the Annotation seemed to be functioning, the digging continued: it turns out the
DefaultDriverFactory
produces only anAnnotationDriver
by default, unless metadata directories are provided.The underlying problem seems to be that the Hateoas builder does not communicate to the JMS builder that a configuration directory was provided.
I managed to work around the problem (while keeping my precious xml config) by pre-configuring the
SerializerBuilder
:Having this working, I quickly found that in order to use expressions from within the xml configuration, I also needed to
setExpressionEvaluator
.It's all working now, but configuring it all becomes a bit awkward:
It seems like relatively easy to fix, I'll try to get a PR in somewhere this week.
TL;DR
HATEOAS builder does not add the MetadataDir nor Expression context variables to the JMS driver, leading to XML and YAML config mostly not working as expected.
The text was updated successfully, but these errors were encountered: