spring-hateoas icon indicating copy to clipboard operation
spring-hateoas copied to clipboard

HATEOAS - Does not render _links correctly

Open fabianfrz opened this issue 3 years ago • 2 comments
trafficstars

Problem:

Server does not add the underscores to the field names and the configuration how to do it correctly is missing for xml based configuration in Jakarta EE environments (war files)

Example:

{"hello":"Hello World","links":[{"rel":"self","href":"http://localhost:8080/hateoas-1.0-SNAPSHOT/mvc/hello-world"}]}

Expected:

  • Solution A: There is some documentation how to initialize it correctly in XML based environments
  • Solution B: There is an actual bug and the bug is fixed

How to reproduce

Example project: Repo https://github.com/fabianfrz/spring-hateoas-bug-example curl http://localhost:8080/hateoas-1.0-SNAPSHOT/mvc/hello-world -H "Accept: application/hal+json"

Additional Information

If the you add the EnableWebMVC annotation, it is starting up, however it seems to configure a different request handler than the one that is actuallly in use. See screenshot. If we don't add the annotation, the augment method is never called.

Screenshot_20220218_153644

fabianfrz avatar Feb 18 '22 14:02 fabianfrz

The documentation outlines that you need a configuration class annotated with @EnableHypermediaSupport. Does that help?

If you'd like us to investigate the sample repo, please ensure it can be run as is (via a test case) and shows the problem.

odrotbohm avatar Feb 18 '22 15:02 odrotbohm

@odrotbohm the annotation is in use by the example project: https://github.com/fabianfrz/spring-hateoas-bug-example/blob/master/src/main/java/com/example/hateoas/EnableHypermedia.java

You can just compile it and deploy it on a WildFly or JBoss server. to get the same environment as we use.

You should get the war if you run maven package and then you can copy the WAR file into WildFly's deploy directory. Then you can reproduce it. If you own a Pro version of IntelliJ IDEA, you can deploy directory from that via a startup config.

fabianfrz avatar Feb 19 '22 18:02 fabianfrz