Skip to content

Instantly share code, notes, and snippets.

@everm1nd
Last active April 11, 2018 16:57
Show Gist options
  • Save everm1nd/1a3bfb29327b83e7e775e5c0b930a2f3 to your computer and use it in GitHub Desktop.
Save everm1nd/1a3bfb29327b83e7e775e5c0b930a2f3 to your computer and use it in GitHub Desktop.
APIGateway configuration for AJAX-endpoint
swagger: '2.0'
info:
title: HTTP-proxy API
description: Example HTTP-proxy API
version: '1.0.0'
schemes:
- https
produces:
- application/json
paths:
/path/to/endpoint/{route+}:
x-amazon-apigateway-any-method:
produces:
- application/json
consumes:
- application/json
x-amazon-apigateway-integration:
type: mock
passthroughBehavior: when_no_templates
responses:
default:
statusCode: "403"
responseParameters:
method.response.header.Access-Control-Allow-Origin: "'*'"
responseTemplates:
application/json: __passthrough__
requestTemplates:
application/json: "{\"statusCode\": 403}"
responses:
403:
headers:
Access-Control-Allow-Origin:
type: string
description: 403 response
get:
produces:
- application/json
consumes:
- application/json
summary: This is a test Lamda HTTP-endpoint
parameters: &parameters
- name: route
in: path
type: string
required: true
x-amazon-apigateway-integration:
type: aws_proxy
httpMethod: POST
uri: %HERE_GOES_YOUR_LAMBDA_ARN%
credentials: %HERE_GOES_YOUR_LAMBDA_INVOCATION_ROLE%
responses:
200:
headers:
Access-Control-Allow-Origin:
type: string
description: Returns the experiment configuration and the destination for a specific target
options:
produces:
- application/json
consumes:
- application/json
summary: OPTIONS method defined for AJAX-calls
parameters:
- name: route
in: path
type: string
required: true
responses:
200:
description: 200 response
headers:
Access-Control-Allow-Origin:
type: string
Access-Control-Allow-Methods:
type: string
Access-Control-Allow-Headers:
type: string
x-amazon-apigateway-integration:
passthroughBehavior: when_no_templates
responses:
default:
statusCode: "200"
responseParameters:
method.response.header.Access-Control-Allow-Methods: "'GET,POST,PUT,PATCH,DELETE,OPTIONS'"
method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
method.response.header.Access-Control-Allow-Origin: "'*'"
responseTemplates:
application/json: __passthrough__
requestTemplates:
application/json: "{\"statusCode\": 200}"
type: mock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment