Hateoas Link format getting different when compare to existing Api response

15 views Asked by At

In Existing Api :(maven Project)

I have a dto class CardDTO which extends ResourceSupport implements Serializable. ResourceSupport is from library org.springframework.hateoas.ResourceSupport in Existing maven project. In pom.xml i have added dependency

<dependency>
      <groupId>org.springframework.hateoas     </groupId>

spring-boot-starter- jdbc

And setting response like this..

CardDAO cardObj = new CardDAO();     // having Id attribute 
CardDTO cardDto =new CardDTO();
cardDto.add(new         Link("/card/"+cardObj.getId(),"card");

Existing Api Response :

"_links":{
    "Card": {
       "href":"/card/725322"
}
}

In New Api :(Gradle Project)

I used same CardDTO class in my new Api and added dependency in build.gradle file as..

implements("org.springframework.hateoas:spring-hateoas:0.16.0.RELEASE")

And setting response like this..

CardDAO cardObj = new CardDAO();     // having Id attribute 
CardDTO cardDto =new CardDTO();
cardDto.add(new     Link("/card/"+cardObj.getId(),"card");

New Api Response:

"links":[
     {   
        "rel": "Card",
        "href": "/card/725322"
     }
]

I want to get response same as Existing api response .

"_links":{

    "Card": {

      "href":"/card/725322"

         }

}

Can you please any one help me on this issue ?

0

There are 0 answers