Closed
Description
I have been searching for information about vendor specific media types that are HAL compatible, and found several issues related to this. Apparently it is possible to easily add custom media types.
However, I'm unable to make returned collections to be embedded.
Taking the CustomHyperMediaWebMvcTest
as an example, and adding a collection:
@GetMapping("/employees")
public CollectionModel<Employee> findOne() {
List<EntityModel<Employee>> employees = new ArrayList();
employees.add(new EntityModel(new Employee("Frodo Baggins", "ring bearer"),
linkTo(methodOn(EmployeeController.class).findOne()).withSelfRel()));
return new CollectionModel(employees);
}
This will return:
{
"links": [],
"content": [
{
"name": "Frodo Baggins",
"role": "ring bearer",
"links": [
{
"rel": "self",
"href": "http://localhost/employees"
}
]
}
]
}
Making the controller endpoint explicitly produce application/frodo+json
has no effect either. However, making the endpoint produce application/hal+json
works as expected:
{
"_embedded": {
"employees": [
{
"name": "Frodo Baggins",
"role": "ring bearer",
"_links": {
"self": {
"href": "http://localhost/employees"
}
}
}
]
}
}
Is there something fundamental I am missing about the configuration, or is this an actual bug?