spring-projects / spring-projects/spring-data-rest

Jackson's @JsonTypeInfo does not serialize correctly when used with As.PROPERTY, As.WRAPPER_OBJECT, or As.WRAPPER_ARRAY [DATAREST-900]

Open
#1,269 3 comments 1 reaction 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

type: bug
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Alex Leigh opened DATAREST-900 and commented

This is a followup to DATAREST-872. Following the fix to that issue, @JsonTypeInfo now works when used with include = JsonTypeInfo.As.EXISTING_PROPERTY. However, for the other three possible values of include, i.e. PROPERTY, WRAPPER_OBJECT, and WRAPPER_ARRAY, the serialized value is not as expected. This is because both the PersistentEntityResourceSerializer and the NestedEntitySerializer are ignoring Jackson's TypeSerializer, so additional type metadata that Jackson normally writes when using @JsonTypeInfo with those three include values are not being written


Affects: 2.5.3 (Hopper SR3)

6 votes, 6 watchers

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.