Skip to content
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

@JsonUnwrapped annotation ignored [DATAREST-880] #1250

Closed
spring-projects-issues opened this issue Aug 29, 2016 · 1 comment
Closed

@JsonUnwrapped annotation ignored [DATAREST-880] #1250

spring-projects-issues opened this issue Aug 29, 2016 · 1 comment
Assignees
Labels
type: bug

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Aug 29, 2016

Pablo Santiago opened DATAREST-880 and commented

Using Spring Boot 1.4.0, Spring Data REST no longer seems to take the @JsonUnwrapped annotation into account to unwrap entities in the JSON responses. The previous Spring Boot versions (i.c. 1.3.7) does not have this problem.

It can be easily reproduced on the master branch of the RestBucks project. When you PUT a payment for an order, the credit card number should be unwrapped, since it is annotated with @JsonUnwrapped, but it is not:

{
  "amount": "EUR4.20",
  "creditCard": {
    "number": {
      "number": "1234123412341234"
    },
    "cardHolderName": "Oliver Gierke",
    "expirationDate": "2099-12-01"
  },
  "_links": {
    "restbucks:order": {
      "href": "http://localhost:8080/orders/1{?projection}",
      "templated": true,
      "title": "An order"
    },
    "curies": [
      {
        "href": "http://localhost:8080/docs/{rel}.html",
        "name": "restbucks",
        "templated": true
      }
    ]
  }
}

The expected output would be (if the @JsonUnwrapped annotation was parsed correctly):

{
  "amount": "EUR4.20",
  "creditCard": {
    "number": "1234123412341234",
    "cardHolderName": "Oliver Gierke",
    "expirationDate": "2099-12-01"
  },
  "_links": {
    "restbucks:order": {
      "href": "http://localhost:8080/orders/1{?projection}",
      "templated": true,
      "title": "An order"
    },
    "curies": [
      {
        "href": "http://localhost:8080/docs/{rel}.html",
        "name": "restbucks",
        "templated": true
      }
    ]
  }
}

This looks like a Spring Data REST bug. Spring Boot 1.3.x uses Spring Data Gosling and @JsonUnwrapped works as expected. However if spring-data-releasetrain.version is overriden to use Spring Data Hopper @JsonUnwrapped no longer works. You can see this behaviour if you check out and run this commit in RestBucks


Affects: 2.5.2 (Hopper SR2)

Reference URL: spring-projects/spring-boot#6722

Referenced from: commits 4cb0632, 7ab5efc

Backported to: 2.5.3 (Hopper SR3)

1 votes, 4 watchers

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Aug 29, 2016

Oliver Drotbohm commented

This is fixed in master and the maintenance for Hopper to be included in Boot 1.4.1. Feel free to give the snapshots a try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug
Projects
None yet
Development

No branches or pull requests

2 participants