skyscreamer / yoga

Yoga is RESTful but flexible.
http://yoga.skyscreamer.org/
Apache License 2.0
156 stars 66 forks source link

JsonSelectorView not working with POST method and @RequestBody input parameter in Spring #248

Open get2parag opened 8 years ago

get2parag commented 8 years ago

While running Yoga on a spring boot application using yoga-springmvc & yoga-core lib v1.06, I faced this issue where the response returned by JsonSelectorView was always coming as empty like "{}" in case of a POST method which is taking an input with @RequestBody spring annotation. Details:- I tried it with a very simple POJO having a @Core annotation over a prepopulated spring attribute.

The API / Controller (& NOT @RestController as suggested) details were like this:- @RequestMapping((value = "/data", method = RequestMethod.POST) public TestDTO getData( @RequestBody DataRequestDTO dataReq)

The yoga config was done as exactly mentioned here : https://github.com/skyscreamer/yoga/wiki/Tutorial:-SpringMVC

The same method starting giving result after removing the @RequestBody annotation while taking entity as input through POST method. I could verify the same by debugging yoga where in while rendering the jsonview the model was showing the type as input request dto instead of the out going test dto and value as empty. Not sure like @ResponseBody-which is prohibited to be used by Yoga, @RequestBody is also messing with the view rendering or if it is a known issue. Let me know if more info is required around the config or POJOs to reproduce this.