x-amazon-apigateway-gateway-responses.responseTemplates 객체 - Amazon API Gateway

x-amazon-apigateway-gateway-responses.responseTemplates 객체

지정된 게이트웨이 응답에 대해 GatewayResponse 매핑 템플릿을 키-값 페어의 문자열 간 맵으로 정의합니다. 각 키-값 페어에 대해 키는 콘텐츠 유형입니다. 예를 들어, “application/json”과 그 값은 간단한 변수 대체를 위해 문자열로 변환된 매핑 템플릿입니다. GatewayResponse 매핑 템플릿은 VTL(Velocity Template Language) 엔진에 의해 처리되지 않습니다.

속성
속성 이름 유형 설명
content-type string

게이트웨이 응답 본문을 사용자 지정하는 단순 변수 대체만 지원하는 GatewayResponse 본문 매핑 템플릿입니다.

x-amazon-apigateway-gateway-responses.responseTemplates 예제

다음과 같은 OpenAPI 확장 예제에서는 API Gateway 생성 오류 응답을 앱 고유 형식으로 사용자 지정하는 GatewayResponse 매핑 템플릿을 보여줍니다.

"responseTemplates": { "application/json": "{ \"message\": $context.error.messageString, \"type\":$context.error.responseType, \"statusCode\": '488' }" }

다음과 같은 OpenAPI 확장 예제에서는 API Gateway 생성 오류 응답을 정적 오류 메시지로 재정의하는 GatewayResponse 매핑 템플릿을 보여줍니다.

"responseTemplates": { "application/json": "{ \"message\": 'API-specific errors' }" }