Заголовок возврата объекта ответа в ответе
Я возвращаю список сообщений об ошибках, используя метод тела ResponseEnitiy. Хотя я не уверен, почему он возвращает объект заголовка в верхней части ответа Ex:
[
{
"headers": {},
"body": {
"code": 6,
"description": "Billing account must not be null!.",
"tcn": "c6fcaa15-bc68-4dc9-87b8-2722ea3e6a20",
"personId": "1087280192",
"errorDetails": null,
"billingAccountsDTO": {
"billingAccountNumber": "",
"debtAmount": 1000.0,
"msisdn": "0554160163",
"hasProblem": true
}
},
"statusCode": "BAD_REQUEST",
"statusCodeValue": 400
},
{
"headers": {},
"body": {
"code": 8,
"description": "Msisnd must not be invalid or null!.",
"tcn": "c6fcaa15-bc68-4dc9-87b8-2722ea3e6a20",
"personId": "1087280192",
"errorDetails": null,
"billingAccountsDTO": {
"billingAccountNumber": "STC234562",
"debtAmount": 0.0,
"msisdn": "05541x60163",
"hasProblem": true
}
},
"statusCode": "BAD_REQUEST",
"statusCodeValue": 400
}
]
Я хочу избавиться от объекта heasers. Странное поведение заключается в том, что я не возвращаю список ответов. заголовки исчезают!!!
снимок реализации ответа:
Response buildResponse(String tcn, ResponseCode responseCode, String personId, BillingAccountsDTO billingAccount) {
Response response =
new Response(responseCode.getCode(), responseCode.getDescription(), tcn, personId, billingAccount,null);
return response;
}
response = ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body(buildResponse(tcn, ResponseCode.INVALID_DEBT_AMOUNT, billingAccountDTO.getPersonId(), billingAccountsDTO));
auditLog.setRequestBody(billingAccountDTO.toString());
auditLog.setResponseCode(ResponseCode.INVALID_DEBT_AMOUNT.getCode());
billingAccountsDTO.setHasProblem(true);
responseList.add(response);
}