I have a class UserMetasource
extending ResourceSupport
(from Spring Hateoas):
public class UserMetasource extends ResourceSupport {
public UserMetasource() {
this.add(linkTo(methodOn(UserController.class).getRoles("roles")));
}
}
Then, in a a controller, I return a UserMetasource
:
@GetMapping("/usermeta")
public UserMetasource getUM() {
return new UserMetasource();
}
This is returning this JSON:
{
links: {
roles: {
href: "bla bla bla"
}
}
}
So good, so far. Now, I have added Swagger to my project:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.4.0</version>
</dependency>
And I have annotated the endpoint like this:
@GetMapping("/usermeta")
@ApiOperation(value = "Get UM", response = UserMetasource.class)
public UserMetasource getUM() {
return new UserMetasource();
}
and now, JSON returned is this one:
{
_links: {
roles: {
href: "bla bla bla"
}
}
}
Note that _links
starts with underscore. Why is that? Is it possible to avoid that? I want links
to be always without underscore.