-
Notifications
You must be signed in to change notification settings - Fork 476
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
Map content in an EntityModel is not properly unwrapped #1157
Comments
As indicated in the linked ticket, there is a POC for this that allows us to refrain from adding yet another representation model base class just to work around a (current) limitation of Jackson. It's all in the works, I just haven't gotten to finish it given all the other fixes I had on my table the last couple of days. |
…nstances. We now register a custom serializer to massage EntityModel instances into dedicated types that – in case of a Map being the content of the entity model – wrap the model into a type that applies the necessary Jackson tweaks to properly unwrap a Map.
That's in place now. Also backported in the context of #1158. |
…g, Object> content. We now keep internal methods in EntityModel that are configured using Jackson annotations so that it'd populate the content with a Map in case Map<String, Content> is defined as payload type.
Using a custom serializer seems to break downstream projects that also register serializers for EntityModel. We're now using extra methods on EntityModel itself that do the trick as well.
Using a custom serializer seems to break downstream projects that also register serializers for EntityModel. We're now using extra methods on EntityModel itself that do the trick as well.
Hi all,
Is it how it is supposed to be? spring-hateoas:1.4.0.RELEASE |
same here (spring-hateoas:1.1.0, jackson:2.11.0, spring-boot:2.3.1) EDIT: just checked the source code, unit tests behaves simillary |
@JsonUnwrapped
is ignored ifEntityModel.content
is a Map.This seems to be a Jackson issue (FasterXML/jackson-databind#171) but it would be nice if the user would not have to figure this out the hard way.
Some thoughts
1. It would be great if EntityModel could be fixed
But I am afraid that there is no simple solution to this issue.
See @odrotbohm comments in this thread: FasterXML/jackson-databind#171 (comment)
2. Validation
There already is a validation that checks if the content is a Collection.
Maybe the validation can also check if the content is a Map:
3. MapModel
It would be great to have a MapModel provided by Spring HATEOAS.
The text was updated successfully, but these errors were encountered: