Skip to content

Latest commit

 

History

History

http_get

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

GET Endpoint with HTTP Integration

This example demonstrates how to specify a GET endpoint for the path /pets which integrates with an HTTP downstream service at https://petstore.example.com.

Configuration

  • The request accepts a query string parameter q and a header Accept-Language which are passed through to the downstream service.
  • The endpoint responds with a 200 if the downstream service responds with a 200 and passes through the response header Content-Language from the downstream service to the client.
  • The endpoint responds with a 500 otherwise.

Given

Generates

  • index.yml

    swagger: "2.0"
    info:
      version: "1.2.3"
      title: "GET Endpoint with HTTP Integration"
      description: |
        This example demonstrates how to specify a GET endpoint for the path `/pets` which integrates with an HTTP
        downstream service at `https://petstore.example.com`.
    
        ## Configuration
    
        * The request accepts a query string parameter `q` and a header `Accept-Language` which are passed through to the
          downstream service.
        * The endpoint responds with a `200` if the downstream service responds with a `200` and passes through the response
          header `Content-Language` from the downstream service to the client.
        * The endpoint responds with a `500` otherwise.
    host: "api.example.com"
    schemes:
      - "https"
    paths:
      /pets:
        get:
          produces:
            - "application/json"
          parameters:
            - name: "q"
              in: "query"
              required: false
              type: "string"
            - name: "Accept-Language"
              in: "header"
              required: false
              type: "string"
          responses:
            '200':
              description: "200 response"
              schema:
                type: "array"
                items:
                  type: "object"
                  properties: {}
              headers:
                Content-Language:
                  type: "string"
            '500':
              description: "500 response"
              schema:
                type: "object"
                properties:
                  message:
                    type: "string"
          x-amazon-apigateway-integration:
            responses:
              default:
                statusCode: "500"
                responseTemplates:
                  application/json: |
                    {
                      "message": "Something went wrong!"
                    }
              ^200$:
                statusCode: "200"
                responseParameters:
                  method.response.header.Content-Language: "integration.response.header.Content-Language"
                responseTemplates:
                  application/json: |
                    $input.path('$')
            requestParameters:
              integration.request.querystring.q: "method.request.querystring.q"
              integration.request.header.Accept-Language: "method.request.header.Accept-Language"
            uri: "https://petstore.example.com"
            passthroughBehavior: "WHEN_NO_TEMPLATES"
            httpMethod: "GET"
            contentHandling: "CONVERT_TO_TEXT"
            type: "http"