openapi: "3.0.0" info: title: @@API_NAME@@ version: "v1.0" x-amazon-apigateway-request-validators: all: validateRequestBody: true validateRequestParameters: true params-only: validateRequestBody: false validateRequestParameters: true x-amazon-apigateway-request-validator: all paths: /ping: get: summary: "Simulates an API Ping" description: | ## Simulates an API Ping The purpose of this endpoint is to simulate a Ping request and respond with a Pong answer. ### Sample invocation ```bash #!/bin/bash # set the desired AWS region below AWS_REGION="us-east-1" STACK_NAME="ApiGatewayDynamicPublish" # Get the API Endpoint API_ENDPOINT_URL_EXPORT_NAME="api-gateway-dynamic-publish-url" API_ENDPOINT_URL=$(aws cloudformation --region ${AWS_REGION} describe-stacks --stack-name ${STACK_NAME} --query "Stacks[0].Outputs[?ExportName=='${API_ENDPOINT_URL_EXPORT_NAME}'].OutputValue" --output text) API_GATEWAY_URL="${API_ENDPOINT_URL}" ################################################ # TEST Ping API ################################################ echo "Testing GET ${API_GATEWAY_URL}/ping" API_RESPONSE=$(curl -sX GET ${API_GATEWAY_URL}/ping) echo "" echo ${API_RESPONSE} echo "" ``` ### Sample response ```json { "ping": "Pong" } ``` operationId: "pingIntegration" x-amazon-apigateway-request-validator: all responses: 200: description: "OK" content: application/json: schema: type: array items: $ref: "#/components/schemas/PingResponse" 500: description: "Internal Server Error" x-amazon-apigateway-integration: uri: @@API_INTEGRATION_PING_LAMBDA@@ payloadFormatVersion: "2.0" httpMethod: "POST" type: "aws_proxy" connectionType: "INTERNET" /greeting: get: summary: "Get a greeting message" description: | ## Get a greeting message The purpose of this endpoint is send a greeting string and receive a greeting message. ### Sample invocation ```bash #!/bin/bash # set the desired AWS region below AWS_REGION="us-east-1" # set the greeting you would like to send, ensure it is a single word with no spaces GREETING="world" STACK_NAME="ApiGatewayDynamicPublish" # Get the API Endpoint API_ENDPOINT_URL_EXPORT_NAME="api-gateway-dynamic-publish-url" API_ENDPOINT_URL=$(aws cloudformation --region ${AWS_REGION} describe-stacks --stack-name ${STACK_NAME} --query "Stacks[0].Outputs[?ExportName=='${API_ENDPOINT_URL_EXPORT_NAME}'].OutputValue" --output text) API_GATEWAY_URL="${API_ENDPOINT_URL}" ################################################ # TEST Greetings API ################################################ echo "Testing GET ${API_GATEWAY_URL}/greetings?greeting=${GREETING}" API_RESPONSE=$(curl -sX GET ${API_GATEWAY_URL}/greetings?greeting=${GREETING}) echo "" echo ${API_RESPONSE} | jq . echo "" ``` ### Sample response ```json { "greeting": "Hello World" } ``` operationId: "greetingIntegration" x-amazon-apigateway-request-validator: all parameters: - in: query name: greeting schema: type: string description: | A greeting string which the API will combine to form a greeting message responses: 200: description: "OK" content: application/json: schema: type: array items: $ref: "#/components/schemas/GreetingResponse" 500: description: "Internal Server Error" x-amazon-apigateway-integration: uri: @@API_INTEGRATION_GREETING_LAMBDA@@ payloadFormatVersion: "2.0" httpMethod: "POST" type: "aws_proxy" connectionType: "INTERNET" components: schemas: PingResponse: type: object properties: ping: type: string description: | Response to the ping request. GreetingResponse: type: object properties: greeting: type: string description: | The greeting response which concatenates the incoming greeting to form a greeting message.