내용으로 건너뛰기

Api Gateway validation response don't include field names

0

Hi, I'm using request validation feature on the Rest Api Gateway and I would like each validation message to contain the name of the field that did not meet the model definition. Is it possible to achieve this on gateway side? I've configured 'Bad Request Body' -> 'Response templates' with following value: {"message": "$context.error.message", "validationString": "$context.error.validationErrorString"} And some of $context.error.validationErrorString values don't include a field name. For example i got response: "validationString": "[instance type (null) does not match any allowed primitive type (allowed: ["string"])]" And it isn't clear which filed has improper format.

1개 답변
0

The issue revolves around API Gateway's request validation responses not consistently including field names in error messages, which complicates identifying which fields failed validation. The current response template setup doesn't reliably extract field names from all validation error strings.

To resolve this, refine your API Gateway response template to extract and display the specific field names that fail validation. Update the template to include logic that parses the validation error string to extract the field names dynamically. Test thoroughly to ensure all validation errors now clearly indicate the affected field names, improving clarity and aiding developers in resolving validation issues effectively.

전문가
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠