Spring Boot - REST method returning interface
<h1><strong>Background</strong></h1>

<p>I've a simple REST API in Spring Boot (<strong>1.4.0.RELEASE</strong>) which should not be connected to a datasource, and as such, needs to take in an object and use it to return another object (<em>interface type</em>) in the same method. This (kind of) unusual behaviour led me to using <code>RequestMethod.POST</code> to both be able to have <strong>@RequestBody</strong> and <strong>@ResponseBody</strong>:</p>

<pre><code>@RestController
public class SomeController {

    @RequestMapping(value = "/path", method = RequestMethod.POST)
    public ResponseEntity&lt;SomeInterface&gt; someMethod(@RequestBody SomeClass obj) {
        SomeInterface toReturn = createSomeInterface(...);
        return new ResponseEntity&lt;&gt;(toReturn, HttpStatus.OK);
    } 
}
</code></pre>

<p>I also have a <code>Test</code> method:</p>

<pre><code>@RunWith(SpringRunner.class)
@SpringBootTest(classes = SomeApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class SomeControllerTests {

    @Autowired
    private TestRestTemplate restTemplate;

    @Test
    public void testSomeMethod() {
        SomeClass toPost = createPostObj();
        ResponseEntity&lt;SomeInterface&gt; respons = this.restTemplate.postForEntity("/path", toPost, SomeInterface.class);
        assertEquals(HttpStatus.OK, respons.getStatusCode());
        assertNotEquals(null, respons.getBody());
    }
}
</code></pre>

<p>However, this throws:</p>

<pre><code>org.springframework.http.converter.HttpMessageNotReadableException: 
Could not read document: 
Can not construct instance of SomeInterface: 
abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
</code></pre>

<h1><strong>Question</strong></h1>

<p>Assuming both <code>SomeInterface</code> and <code>SomeClass</code> are belongings to other <em>API's</em> and can't be changed, is this possible to accomplish? </p>

<p><strong>Note</strong></p>

<p>I've tried to wrap the <code>SomeInterface</code> into a class without success:</p>

<pre><code>public class Wrapper {
    SomeInterface obj;
    // getter and setter ...
}
</code></pre>