-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Wrong Resource Type" When Collection Misses "_embedded" #66
Comments
Hi @mathias-ewald ! In this case, I relied on This behavior allows simpler to determine what is Resource type: As I understand you use HalModelBuilder.emptyHalModel()
.embed(Collections.emptyList(), Order.class);
// or
.embed(Collections.emptyList(), LinkRelation.of("orders")); Then it will be rendered the next JSON for an empty collection: {
"_embedded" : {
"orders" : []
}
} See more in |
If you can not make an empty |
Hi @lagoshny, think it'll be difficult to tell the backend team to do something the specification does not require to be compatible with the frontend library I am using. Is there a way to catch and handle that error somehow? cheers, |
@mathias-ewald To help you, I added new config option that allow resource collections without Add option in lib config (see more in docs): halFormat: {
collections: {
embeddedOptional: true
}
} This features available since |
Hi wrote a REST API with Spring HATEOAS and noticed that when there are not resources to return, the rendered JSON misses the
_embedded
property.Code from the REST controller that produces the result:
The result produced when there are no entities in the repository:
The UI code to fetch the data:
Error produced in the UI:

Since the HAL specification (https://datatracker.ietf.org/doc/html/draft-kelly-json-hal#section-4.1.2) tells that
_embedded
is optional, I am opening an issues here.The text was updated successfully, but these errors were encountered: