excilys/androidannotations — Issue #114: On @Post: Response different than entity parameter generates wrong client Java code
Author: rylexr
Created: 2012-02-18 03:03:10+00:00
State: open

Suppose the following code:

```java
@Rest(...)
public interface MyRestClient {
@Post(...)
ResponseEntity foo(EntityToBeSend e);
}
```
The 'generator' outputs a wrong code implementation (MyRestClient_.java) because it expects the EntityToBeSend and EntityToBeReturned the same. The Java code looks like:

```java
public ResponseEntity foo(EntityToBeSend e) {
HttpHeaders httpHeaders = new HttpHeaders();
HttpEntity requestEntity = new HttpEntity(e, httpHeaders); // this is wrong and generates a compile time error
return restTemplate.exchange("...", HttpMethod.POST, requestEntity, EntityToBeReturned.class);
}
```
The fix should be something like:

```java
public ResponseEntity foo(EntityToBeSend e) {
HttpHeaders httpHeaders = new HttpHeaders();
HttpEntity requestEntity = new HttpEntity(e, httpHeaders); // Change this line to the right entity type
return restTemplate.exchange("...", HttpMethod.POST, requestEntity, EntityToBeReturned.class);
}
```

I think this is a bug because generator mixes the types between the sent and the returned entity.

Thanks (sorry for my english).