

# API Gateway의 REST API 대한 파라미터 매핑
<a name="rest-api-parameter-mapping"></a>

**참고**  
HTTP API를 사용하는 경우 [API Gateway에서 HTTP API에 대한 API 요청 및 응답 변환](http-api-parameter-mapping.md) 섹션을 참조하시기 바랍니다.

파라미터 매핑에서 요청 또는 응답 파라미터를 매핑합니다. 파라미터 매핑 표현식 또는 정적 값을 사용하여 파라미터를 매핑할 수 있습니다. 매핑 표현식 목록은 [API Gateway의 REST API에 대한 파라미터 매핑 소스 참조](rest-api-parameter-mapping-sources.md) 섹션을 참조하시기 바랍니다. 프록시 및 비 프록시 통합에 대한 통합 요청에서 파라미터 매핑을 사용할 수 있지만 통합 응답에 파라미터 매핑을 사용하려면 비 프록시 통합이 필요합니다.

예를 들어 메서드 요청 헤더 파라미터(`puppies`)를 통합 요청 헤더 파라미터(`DogsAge0`)에 매핑할 수 있습니다. 그런 다음 클라이언트가 API로 `puppies:true` 헤더를 보내면 통합 요청은 요청 헤더(`DogsAge0:true`)를 통합 엔드포인트로 보냅니다. 다음 다이어그램은 이 예제의 요청 수명 주기를 보여줍니다.

![\[요청에 대한 API Gateway 파라미터 매핑 예제 다이어그램\]](http://docs.aws.amazon.com/ko_kr/apigateway/latest/developerguide/images/parameter-mapping-example1.png)


API Gateway를 사용하여 이 예제를 만들려면 [예제 1: 메서드 요청 파라미터를 통합 요청 파라미터에 매핑](request-response-data-mappings.md#request-response-data-mappings-example-1) 섹션을 참조하시기 바랍니다.

 또 다른 예제로, 통합 응답 헤더 파라미터(`kittens`)를 메서드 응답 헤더 파라미터(`CatsAge0`)에 매핑할 수 있습니다. 그런 다음 통합 엔드포인트가 `kittens:false`를 반환하면 클라이언트는 `CatsAge0:false` 헤더를 수신합니다. 다음 다이어그램은 이 예제의 요청 수명 주기를 보여줍니다.

![\[응답에 대한 API Gateway 파라미터 매핑 예제 다이어그램\]](http://docs.aws.amazon.com/ko_kr/apigateway/latest/developerguide/images/parameter-mapping-example2.png)


**Topics**
+ [API Gateway의 REST API에 대한 파라미터 매핑 예제](request-response-data-mappings.md)
+ [API Gateway의 REST API에 대한 파라미터 매핑 소스 참조](rest-api-parameter-mapping-sources.md)

# API Gateway의 REST API에 대한 파라미터 매핑 예제
<a name="request-response-data-mappings"></a>

다음 예제에서는 API Gateway 콘솔, OpenAPI 및 CloudFormation 템플릿을 사용하여 파라미터 매핑 표현식을 만드는 방법을 보여줍니다. 파라미터 매핑을 사용하여 필요한 CORS 헤더를 만드는 방법의 예제는 [API Gateway의 REST API CORS](how-to-cors.md) 섹션을 참조하시기 바랍니다.

## 예제 1: 메서드 요청 파라미터를 통합 요청 파라미터에 매핑
<a name="request-response-data-mappings-example-1"></a>

다음 예제에서는 메서드 요청 헤더 파라미터(`puppies`)를 통합 요청 헤더 파라미터(`DogsAge0`)에 매핑합니다.

------
#### [ AWS Management Console ]

**메서드 요청 파라미터 매핑**

1. [https://console.aws.amazon.com/apigateway](https://console.aws.amazon.com/apigateway)에서 API Gateway 콘솔에 로그인합니다.

1. REST API를 선택합니다.

1. 방법을 선택합니다.

   메서드에는 비프록시 통합이 있어야 합니다.

1. **메서드 요청 설정** 섹션에서 **편집**을 선택합니다.

1. **HTTP 요청 헤더**를 선택합니다.

1. **헤더 추가(Add header)**를 선택합니다.

1. **이름**에 **puppies**를 입력합니다.

1. **저장**을 선택합니다.

1. **통합 요청** 탭을 선택한 다음 **통합 요청 설정**에서 **편집**을 선택합니다.

   AWS Management Console은 `method.request.header.puppies `에서 `puppies`로 파라미터 매핑을 자동으로 추가하지만 통합 엔드포인트에서 예상되는 요청 헤더 파라미터와 일치하도록 **이름**을 변경해야 합니다.

1. **이름**에 **DogsAge0**를 입력합니다.

1. **저장**을 선택합니다.

1. 변경 사항을 적용하려면 API를 재배포합니다.

다음 단계에서는 파라미터 매핑이 성공했는지 확인하는 방법을 보여줍니다.

**(선택 사항) 파라미터 매핑 테스트**

1. **테스트** 탭을 선택합니다. 탭을 표시하려면 오른쪽 화살표 버튼을 선택해야 할 수도 있습니다.

1. 헤더에 **puppies:true**를 입력합니다.

1. **테스트**를 선택합니다.

1. **로그**에 다음과 같은 결과가 표시되어야 합니다.

   ```
   Tue Feb 04 00:28:36 UTC 2025 : Method request headers: {puppies=true}
   Tue Feb 04 00:28:36 UTC 2025 : Method request body before transformations: 
   Tue Feb 04 00:28:36 UTC 2025 : Endpoint request URI: http://petstore-demo-endpoint.execute-api.com/petstore/pets
   Tue Feb 04 00:28:36 UTC 2025 : Endpoint request headers: {DogsAge0=true, x-amzn-apigateway-api-id=abcd1234, Accept=application/json, User-Agent=AmazonAPIGateway_aaaaaaa, X-Amzn-Trace-Id=Root=1-abcd-12344}
   ```

   요청 헤더 파라미터가 `puppies`에서 `DogsAge0`으로 변경되었습니다.

------
#### [ CloudFormation ]

 이 예제에서는 [본문](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-body) 속성을 사용하여 OpenAPI 정의 파일을 API Gateway로 가져옵니다.

```
AWSTemplateFormatVersion: 2010-09-09
Resources:
  Api:
    Type: 'AWS::ApiGateway::RestApi'
    Properties:
      Body:
        openapi: 3.0.1
        info:
          title: ParameterMappingExample
          version: "2025-02-04T00:30:41Z"
        paths:
          /pets:
            get:
              parameters:
                - name: puppies
                  in: header
                  schema:
                    type: string
              responses:
                "200":
                  description: 200 response
              x-amazon-apigateway-integration:
                httpMethod: GET
                uri: http://petstore-demo-endpoint.execute-api.com/petstore/pets
                responses:
                  default:
                    statusCode: "200"
                requestParameters:
                  integration.request.header.DogsAge0: method.request.header.puppies
                passthroughBehavior: when_no_match
                type: http
  ApiGatewayDeployment:
    Type: 'AWS::ApiGateway::Deployment'
    DependsOn: Api 
    Properties: 
      RestApiId: !Ref Api
  ApiGatewayDeployment20250219:
    Type: 'AWS::ApiGateway::Deployment'
    DependsOn: Api 
    Properties: 
      RestApiId: !Ref Api
  Stage:
    Type: 'AWS::ApiGateway::Stage'
    Properties:
       DeploymentId: !Ref ApiGatewayDeployment20250219
       RestApiId: !Ref Api
       StageName: prod
```

------
#### [ OpenAPI ]

```
{
  "openapi" : "3.0.1",
  "info" : {
    "title" : "ParameterMappingExample",
    "version" : "2025-02-04T00:30:41Z"
  },
  "paths" : {
    "/pets" : {
      "get" : {
        "parameters" : [ {
          "name" : "puppies",
          "in" : "header",
          "schema" : {
            "type" : "string"
          }
        } ],
        "responses" : {
          "200" : {
            "description" : "200 response"
          }
        },
        "x-amazon-apigateway-integration" : {
          "httpMethod" : "GET",
          "uri" : "http://petstore-demo-endpoint.execute-api.com/petstore/pets",
          "responses" : {
            "default" : {
              "statusCode" : "200"
            }
          },
          "requestParameters" : {
            "integration.request.header.DogsAge0" : "method.request.header.puppies"
          },
          "passthroughBehavior" : "when_no_match",
          "type" : "http"
        }
      }
    }
  }
}
```

------

## 예제 2: 여러 메서드 요청 파라미터를 다른 통합 요청 파라미터에 매핑
<a name="request-response-data-mappings-example-2"></a>

다음 예제에서는 다중 값 메서드 요청 쿼리 문자열 파라미터(`methodRequestQueryParam`)를 통합 요청 쿼리 문자열 파라미터(`integrationQueryParam`)에 매핑하고 메서드 요청 헤더 파라미터(`methodRequestHeaderParam`)를 통합 요청 경로 파라미터(`integrationPathParam`)에 매핑합니다.

------
#### [ AWS Management Console ]

**메서드 요청 파라미터 매핑**

1. [https://console.aws.amazon.com/apigateway](https://console.aws.amazon.com/apigateway)에서 API Gateway 콘솔에 로그인합니다.

1. REST API를 선택합니다.

1. 방법을 선택합니다.

   메서드에는 비프록시 통합이 있어야 합니다.

1. **메서드 요청 설정** 섹션에서 **편집**을 선택합니다.

1. **URL 쿼리 문자열 파라미터**를 선택합니다.

1. **쿼리 문자열 추가(Add query string)**를 선택합니다.

1. **이름**에 **methodRequestQueryParam**를 입력합니다.

1. **HTTP 요청 헤더**를 선택합니다.

1. **헤더 추가(Add header)**를 선택합니다.

1. **이름**에 **methodRequestHeaderParam**를 입력합니다.

1. **저장**을 선택합니다.

1. **통합 요청** 탭을 선택한 다음 **통합 요청 설정**에서 **편집**을 선택합니다.

1. **URL 경로 파라미터**를 선택합니다.

1. **경로 파라미터 추가**를 선택합니다.

1. **이름**에 **integrationPathParam**를 입력합니다.

1. **다음에서 매핑됨**에 **method.request.header.methodRequestHeaderParam**을 입력합니다.

   그러면 메서드 요청에서 지정한 메서드 요청 헤더가 새 통합 요청 경로 파라미터에 매핑됩니다.

1. **URL 쿼리 문자열 파라미터**를 선택합니다.

1. **쿼리 문자열 추가(Add query string)**를 선택합니다.

1. **이름**에 **integrationQueryParam**를 입력합니다.

1. **다음에서 매핑됨**에 **method.request.multivaluequerystring.methodRequestQueryParam**을 입력합니다.

   그러면 다중 값 쿼리 문자열 파라미터가 새로운 단일 값 통합 요청 쿼리 문자열 파라미터에 매핑됩니다.

1. **저장**을 선택합니다.

1. 변경 사항을 적용하려면 API를 재배포합니다.

------
#### [ CloudFormation ]

 이 예제에서는 [본문](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-body) 속성을 사용하여 OpenAPI 정의 파일을 API Gateway로 가져옵니다.

다음 OpenAPI 정의는 HTTP 통합에 대해 다음과 같은 파라미터 매핑을 만듭니다.
+ `methodRequestHeaderParam`이라는 메서드 요청 헤더를 `integrationPathParam`이라는 통합 요청 경로 파라미터로 매핑합니다.
+ `methodRequestQueryParam`이라는 다중 값 메서드 요청 쿼리 문자열은 `integrationQueryParam`이라는 통합 요청 쿼리 문자열에 매핑됩니다.

```
AWSTemplateFormatVersion: 2010-09-09
Resources:
  Api:
    Type: 'AWS::ApiGateway::RestApi'
    Properties:
      Body: 
        openapi: 3.0.1
        info:
          title: Parameter mapping example 2
          version: "2025-01-15T19:12:31Z"
        paths:
          /:
            post:
              parameters:
                - name: methodRequestQueryParam
                  in: query
                  schema:
                    type: string
                - name: methodRequestHeaderParam
                  in: header
                  schema:
                    type: string
              responses:
                "200":
                  description: 200 response
              x-amazon-apigateway-integration:
                httpMethod: GET
                uri: http://petstore-demo-endpoint.execute-api.com/petstore/pets
                responses:
                  default:
                    statusCode: "200"
                requestParameters:
                  integration.request.querystring.integrationQueryParam: method.request.multivaluequerystring.methodRequestQueryParam
                  integration.request.path.integrationPathParam: method.request.header.methodRequestHeaderParam
                requestTemplates:
                  application/json: '{"statusCode": 200}'
                passthroughBehavior: when_no_templates
                timeoutInMillis: 29000
                type: http
  ApiGatewayDeployment:
    Type: 'AWS::ApiGateway::Deployment'
    DependsOn: Api 
    Properties: 
      RestApiId: !Ref Api
  ApiGatewayDeployment20250219:
    Type: 'AWS::ApiGateway::Deployment'
    DependsOn: Api 
    Properties: 
      RestApiId: !Ref Api
  Stage:
    Type: 'AWS::ApiGateway::Stage'
    Properties:
       DeploymentId: !Ref ApiGatewayDeployment20250219
       RestApiId: !Ref Api
       StageName: prod
```

------
#### [ OpenAPI ]

다음 OpenAPI 정의는 HTTP 통합에 대해 다음과 같은 파라미터 매핑을 만듭니다.
+ `methodRequestHeaderParam`이라는 메서드 요청 헤더를 `integrationPathParam`이라는 통합 요청 경로 파라미터로 매핑합니다.
+ `methodRequestQueryParam`이라는 다중 값 메서드 요청 쿼리 문자열은 `integrationQueryParam`이라는 통합 요청 쿼리 문자열에 매핑됩니다.

```
{
  "openapi" : "3.0.1",
  "info" : {
    "title" : "Parameter mapping example 2",
    "version" : "2025-01-15T19:12:31Z"
  },
  "paths" : {
    "/" : {
      "post" : {
        "parameters" : [ {
          "name" : "methodRequestQueryParam",
          "in" : "query",
          "schema" : {
            "type" : "string"
          }
        }, {
          "name" : "methodRequestHeaderParam",
          "in" : "header",
          "schema" : {
            "type" : "string"
          }
        } ],
        "responses" : {
          "200" : {
            "description" : "200 response"
          }
        },
        "x-amazon-apigateway-integration" : {
          "httpMethod" : "GET",
          "uri" : "http://petstore-demo-endpoint.execute-api.com/petstore/pets",
          "responses" : {
            "default" : {
              "statusCode" : "200"
            }
          },
          "requestParameters" : {
            "integration.request.querystring.integrationQueryParam" : "method.request.multivaluequerystring.methodRequestQueryParam",
            "integration.request.path.integrationPathParam" : "method.request.header.methodRequestHeaderParam"
          },
          "requestTemplates" : {
            "application/json" : "{\"statusCode\": 200}"
          },
          "passthroughBehavior" : "when_no_templates",
          "timeoutInMillis" : 29000,
          "type" : "http"
        }
      }
    }
  }
}
```

------

## 예제 3: JSON 요청 본문의 필드를 통합 요청 파라미터에 매핑
<a name="request-response-data-mappings-example-3"></a>

또한 [JSONPath 표현식](http://goessner.net/articles/JsonPath/index.html#e2)을 사용하여 JSON 요청 본문의 필드에서 통합 요청 파라미터를 매핑할 수 있습니다. 다음 예제에서는 메서드 요청 본문을 `body-header`라는 통합 요청 헤더에 매핑하고 JSON 표현식으로 표현되는 요청 본문의 일부를 `pet-price`라는 통합 요청 헤더에 매핑합니다.

이 예제를 테스트하려면 다음과 같이 가격 범주가 포함된 입력을 제공합니다.

```
[ 
  { 
    "id": 1, 
    "type": "dog", 
    "price": 249.99 
  }
]
```

------
#### [ AWS Management Console ]

**메서드 요청 파라미터 매핑**

1. [https://console.aws.amazon.com/apigateway](https://console.aws.amazon.com/apigateway)에서 API Gateway 콘솔에 로그인합니다.

1. REST API를 선택합니다.

1. `POST`, `PUT`, `PATCH` 또는 `ANY` 메서드를 선택합니다.

   메서드에는 비프록시 통합이 있어야 합니다.

1. **통합 요청 설정**에서 **편집**을 선택합니다.

1. **요청 헤더 파라미터**를 선택합니다.

1. **요청 헤더 파라미터 추가**를 선택합니다.

1. **이름**에 **body-header**를 입력합니다.

1. **다음에서 매핑됨**에 **method.request.body**을 입력합니다.

   그러면 메서드 요청 본문이 새 통합 요청 헤더 파라미터에 매핑됩니다.

1. **요청 헤더 파라미터 추가**를 선택합니다.

1. **이름**에 **pet-price**를 입력합니다.

1. **다음에서 매핑됨**에 ** method.request.body[0].price**을 입력합니다.

   그러면 메서드 요청 본문의 일부가 새 통합 요청 헤더 파라미터에 매핑됩니다.

1. **저장**을 선택합니다.

1. 변경 사항을 적용하려면 API를 재배포합니다.

------
#### [ CloudFormation ]

 이 예제에서는 [본문](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-body) 속성을 사용하여 OpenAPI 정의 파일을 API Gateway로 가져옵니다.

```
AWSTemplateFormatVersion: 2010-09-09
Resources:
  Api:
    Type: 'AWS::ApiGateway::RestApi'
    Properties:
      Body: 
        openapi: 3.0.1
        info:
          title: Parameter mapping example 3
          version: "2025-01-15T19:19:14Z"
        paths:
          /:
            post:
              responses:
                "200":
                  description: 200 response
              x-amazon-apigateway-integration:
                httpMethod: GET
                uri: http://petstore-demo-endpoint.execute-api.com/petstore/pets
                responses:
                  default:
                    statusCode: "200"
                requestParameters:
                  integration.request.header.pet-price: method.request.body[0].price
                  integration.request.header.body-header: method.request.body
                requestTemplates:
                  application/json: '{"statusCode": 200}'
                passthroughBehavior: when_no_templates
                timeoutInMillis: 29000
                type: http
  ApiGatewayDeployment:
    Type: 'AWS::ApiGateway::Deployment'
    DependsOn: Api 
    Properties: 
      RestApiId: !Ref Api
  ApiGatewayDeployment20250219:
    Type: 'AWS::ApiGateway::Deployment'
    DependsOn: Api 
    Properties: 
      RestApiId: !Ref Api
  Stage:
    Type: 'AWS::ApiGateway::Stage'
    Properties:
       DeploymentId: !Ref ApiGatewayDeployment20250219
       RestApiId: !Ref Api
       StageName: prod
```

------
#### [ OpenAPI ]

다음 OpenAPI 정의는 JSON 요청 본문의 필드에서 통합 요청 파라미터를 매핑합니다.

```
{
  "openapi" : "3.0.1",
  "info" : {
    "title" : "Parameter mapping example 3",
    "version" : "2025-01-15T19:19:14Z"
  },
  "paths" : {
    "/" : {
      "post" : {
        "responses" : {
          "200" : {
            "description" : "200 response"
          }
        },
        "x-amazon-apigateway-integration" : {
          "httpMethod" : "GET",
          "uri" : "http://petstore-demo-endpoint.execute-api.com/petstore/pets",
          "responses" : {
            "default" : {
              "statusCode" : "200"
            }
          },
          "requestParameters" : {
            "integration.request.header.pet-price" : "method.request.body[0].price",
            "integration.request.header.body-header" : "method.request.body"
          },
          "requestTemplates" : {
            "application/json" : "{\"statusCode\": 200}"
          },
          "passthroughBehavior" : "when_no_templates",
          "timeoutInMillis" : 29000,
          "type" : "http"
        }
      }
    }
  }
}
```

------

## 예제 4: 통합 응답을 메서드 응답에 매핑
<a name="request-response-data-mappings-example-4"></a>

또한 통합 응답을 메서드 응답에 매핑할 수 있습니다. 다음 예제에서는 통합 응답 본문을 `location`이라는 메서드 응답 헤더에 매핑하고, 통합 응답 헤더(`x-app-id`)를 메서드 응답 헤더(`id`)에 매핑하고, 다중 값 통합 응답 헤더(`item`)를 메서드 응답 헤더(`items`)에 매핑합니다.

------
#### [ AWS Management Console ]

**통합 응답 매핑**

1. [https://console.aws.amazon.com/apigateway](https://console.aws.amazon.com/apigateway)에서 API Gateway 콘솔에 로그인합니다.

1. REST API를 선택합니다.

1. 방법을 선택합니다.

   메서드에는 비프록시 통합이 있어야 합니다.

1. **메서드 응답** 탭을 선택한 다음 **응답 200**에서 **편집**을 선택합니다.

1. **헤더 이름**에서 **헤더 추가**를 선택합니다.

1. **id**, **item** 및 **location**이라는 헤더 3개를 만듭니다.

1. **저장**을 선택합니다.

1. **통합 응답** 탭을 선택한 다음, **기본값 - 응답**에서 **편집**을 선택합니다.

1. **헤더 매핑** 아래에서 다음을 입력합니다.

   1. **id**에 **integration.response.header.x-app-id**를 입력합니다.

   1. **항목**에 **integration.response.multivalueheader.item**을 입력합니다.

   1. **위치**에 **integration.response.body.redirect.url**을 입력합니다.

1. **저장**을 선택합니다.

1. 변경 사항을 적용하려면 API를 재배포합니다.

------
#### [ CloudFormation ]

 이 예제에서는 [본문](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-body) 속성을 사용하여 OpenAPI 정의 파일을 API Gateway로 가져옵니다.

```
AWSTemplateFormatVersion: 2010-09-09
Resources:
  Api:
    Type: 'AWS::ApiGateway::RestApi'
    Properties:
      Body:
        openapi: 3.0.1
        info:
          title: Parameter mapping example
          version: "2025-01-15T19:21:35Z"
        paths:
          /:
            post:
              responses:
                "200":
                  description: 200 response
                  headers:
                    item:
                      schema:
                        type: string
                    location:
                      schema:
                        type: string
                    id:
                      schema:
                        type: string
              x-amazon-apigateway-integration:
                type: http
                httpMethod: GET
                uri: http://petstore-demo-endpoint.execute-api.com/petstore/pets
                responses:
                  default:
                    statusCode: "200"
                    responseParameters:
                      method.response.header.id: integration.response.header.x-app-id
                      method.response.header.location: integration.response.body.redirect.url
                      method.response.header.item: integration.response.multivalueheader.item
                requestTemplates:
                  application/json: '{"statusCode": 200}'
                passthroughBehavior: when_no_templates
                timeoutInMillis: 29000
  ApiGatewayDeployment:
    Type: 'AWS::ApiGateway::Deployment'
    DependsOn: Api 
    Properties: 
      RestApiId: !Ref Api
  ApiGatewayDeployment20250219:
    Type: 'AWS::ApiGateway::Deployment'
    DependsOn: Api 
    Properties: 
      RestApiId: !Ref Api
  Stage:
    Type: 'AWS::ApiGateway::Stage'
    Properties:
       DeploymentId: !Ref ApiGatewayDeployment20250219
       RestApiId: !Ref Api
       StageName: prod
```

------
#### [ OpenAPI ]

다음 OpenAPI 정의는 통합 응답을 메서드 응답에 매핑합니다.

```
{
  "openapi" : "3.0.1",
  "info" : {
    "title" : "Parameter mapping example",
    "version" : "2025-01-15T19:21:35Z"
  },
  "paths" : {
    "/" : {
      "post" : {
        "responses" : {
          "200" : {
            "description" : "200 response",
            "headers" : {
              "item" : {
                "schema" : {
                  "type" : "string"
                }
              },
              "location" : {
                "schema" : {
                  "type" : "string"
                }
              },
              "id" : {
                "schema" : {
                  "type" : "string"
                }
              }
            }
          }
        },
        "x-amazon-apigateway-integration" : {
          "type" : "http",
          "httpMethod" : "GET",
          "uri" : "http://petstore-demo-endpoint.execute-api.com/petstore/pets",
          "responses" : {
            "default" : {
              "statusCode" : "200",
              "responseParameters" : {
                "method.response.header.id" : "integration.response.header.x-app-id",
                "method.response.header.location" : "integration.response.body.redirect.url",
                "method.response.header.item" : "integration.response.multivalueheader.item"
              }
            }
          },
          "requestTemplates" : {
            "application/json" : "{\"statusCode\": 200}"
          },
          "passthroughBehavior" : "when_no_templates",
          "timeoutInMillis" : 29000
        }
      }
    }
  }
}
```

------

# API Gateway의 REST API에 대한 파라미터 매핑 소스 참조
<a name="rest-api-parameter-mapping-sources"></a>

파라미터 매핑을 만들 경우 수정할 메서드 요청 또는 통합 응답 파라미터를 지정하고 이러한 파라미터를 수정하는 방법을 지정합니다.

다음 표에는 매핑할 수 있는 메서드 요청 파라미터와 매핑을 만드는 표현식이 나와 있습니다. 이러한 표현식에서 *name*은 메서드 요청 파라미터의 이름입니다. 예를 들어 요청 헤더 파라미터(`puppies`)를 매핑하려면 `method.request.header.puppies` 표현식을 사용합니다. 표현식은 `'^[a-zA-Z0-9._$-]+$]'` 정규 표현식과 일치해야 합니다. 프록시 및 비 프록시 통합에 대한 통합 요청에서 파라미터 매핑을 사용할 수 있습니다.


| **매핑된 데이터 소스** | **매핑 표현식** | 
| --- | --- | 
| 메서드 요청 경로 | method.request.path.name | 
| 메서드 요청 쿼리 문자열 | method.request.querystring.name | 
| 다중 값 메서드 요청 쿼리 문자열 | method.request.multivaluequerystring.name | 
| 메서드 요청 헤더 | method.request.header.name | 
| 다중 값 메서드 요청 헤더 | method.request.multivalueheader.name | 
| 메서드 요청 본문 | method.request.body | 
| 메서드 요청 본문(JsonPath) | `method.request.body.JSONPath_EXPRESSION`. *JSONPath\$1EXPRESSION*은 요청 본문의 JSON 필드에 대한 JSONPath 표현식입니다. 자세한 내용은 [JSONPath 표현식](http://goessner.net/articles/JsonPath/index.html#e2)을 참조하시기 바랍니다.  | 
| 단계 변수 | stageVariables.name | 
| 컨텍스트 변수 |  `context.name` 이름은 [지원되는 컨텍스트 변수](api-gateway-mapping-template-reference.md#context-variable-reference) 중 하나여야 합니다. | 
| 정적 값 | `'static_value'`. *static\$1value*는 문자열 리터럴이며 작은따옴표 쌍으로 묶여야 합니다. 예를 들어 `'https://www.example.com'`입니다. | 

다음 표에는 매핑할 수 있는 통합 응답 파라미터와 매핑을 만드는 표현식이 나와 있습니다. 이러한 표현식에서 *name*은 통합 응답 파라미터의 이름입니다. 통합 응답 헤더 또는 통합 응답 본문, \$1context 변수 또는 정적 값에서 메서드 응답 헤더를 매핑할 수 있습니다. 통합 응답에 파라미터 매핑을 사용하려면 비 프록시 통합이 필요합니다.


| 매핑된 데이터 원본 | 매핑 표현식 | 
| --- | --- | 
| 통합 응답 헤더 | integration.response.header.name | 
| 통합 응답 헤더 | integration.response.multivalueheader.name | 
| 통합 응답 본문 | integration.response.body | 
| 통합 응답 본문(JsonPath) | `integration.response.body.JSONPath_EXPRESSION` *JSONPath\$1EXPRESSION*은 응답 본문의 JSON 필드에 대한 JSONPath 표현식입니다. 자세한 내용은 [JSONPath 표현식](http://goessner.net/articles/JsonPath/index.html#e2)을 참조하시기 바랍니다. | 
| 단계 변수 | stageVariables.name | 
| 컨텍스트 변수 |  `context.name` 이름은 [지원되는 컨텍스트 변수](api-gateway-mapping-template-reference.md#context-variable-reference) 중 하나여야 합니다. | 
| 정적 값 | ` 'static_value'` *static\$1value*는 문자열 리터럴이며 작은따옴표 쌍으로 묶여야 합니다. 예를 들어 `'https://www.example.com'`입니다. | 