Skip to content

Instantly share code, notes, and snippets.

@berndverst
Created January 25, 2018 00:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save berndverst/b59fa0b38544f13c05ae0b77f21d9939 to your computer and use it in GitHub Desktop.
Save berndverst/b59fa0b38544f13c05ae0b77f21d9939 to your computer and use it in GitHub Desktop.
Swagger 2.0 definition for AWS API Gateway endpoint to Proxy API requests and add API client ID and secret
{
"swagger": "2.0",
"info": {
"version": "2016-09-12T23:19:28Z",
"title": "ProxyAPIwithCreds"
},
"host": "my-domain.com",
"basePath": "/test",
"schemes": [
"https"
],
"paths": {
"/search/{proxy+}": {
"x-amazon-apigateway-any-method": {
"produces": [
"application/json"
],
"parameters": [
{
"name": "proxy",
"in": "path",
"required": true,
"type": "string"
}
],
"responses": {},
"x-amazon-apigateway-integration": {
"responses": {
"default": {
"statusCode": "200"
}
},
"requestParameters": {
"integration.request.path.proxy": "method.request.path.proxy",
"integration.request.querystring.client_id": "'XXXXXXXXX'",
"integration.request.querystring.client_secret": "'ZZZZZZZZZ'"
},
"uri": "https://external-domain.com/api/{proxy}",
"passthroughBehavior": "when_no_match",
"httpMethod": "ANY",
"type": "http_proxy"
}
}
}
}
}
@berndverst
Copy link
Author

  • Replace XXXXXXXXX with your API client ID and replace ZZZZZZZZZ with your API client secret. Any other parameters are passed through.
  • Update the x-amazon-apigateway-integration's uri field with the desired API endpoint to proxy to.

AWS Instructions: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-import-api.html
Also see the child articles for the different ways to import the Swagger 2.0 template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment