I have classes generated from .raml file. In the generated interface for controller I have @RequestBody on my parameter. If I try to make request, mapping works correct but every time I have null fields in my Object annotated with @RequestBody from parameters. Looks like this annotation is ignored. How can I make it work from interface.
For testing without Raml I tried to create a simple interface for controller with simple implementation and I'm still getting null fields values in my request object.
Controller interface generated from .raml
@RestController
@RequestMapping("/kbm")
public interface KbmController {
@RequestMapping(value = "", method = RequestMethod.PUT)
public ResponseEntity<KbmCalcResponse> updateKbm(
@Valid
@RequestBody
KbmCalcRequest kbmCalcRequest);
}
My implementation
@Component
@RequiredArgsConstructor
public class CalcKbmControllerImpl implements KbmController {
private final KbmService kbmService;
@Override
public ResponseEntity<KbmCalcResponse> updateKbm(KbmCalcRequest kbmCalcRequest) {
System.out.println(kbmCalcRequest.getInsurerID());
return ResponseEntity.ok(kbmService.calculate(kbmCalcRequest));
}
}
Request model generated from .raml
public class KbmCalcRequest implements Serializable
{
final static long serialVersionUID = 1692733266431420440L;
private String insurerID;
public KbmCalcRequest() {
super();
}
public KbmCalcRequest(String insurerID {
super();
this.insurerID = insurerID;
}
public String getInsurerID() {
return insurerID;
}
public void setInsurerID(String insurerID) {
this.insurerID = insurerID;
}
public int hashCode() {
return new HashCodeBuilder().append(insurerID).toHashCode();
}
public boolean equals(Object other) {
if (other == null) {
return false;
}
if (other == this) {
return true;
}
if (this.getClass()!= other.getClass()) {
return false;
}
KbmCalcRequest otherObject = ((KbmCalcRequest) other);
return new EqualsBuilder().append(insurerID, otherObject.insurerID).isEquals();
}
public String toString() {
return new ToStringBuilder(this).append("insurerID", insurerID).toString();
}
}