openapi: "3.0.1"
info:
  title: "SkeletonProductFeedbackAPI"
  version: "2020-11-06 15:32:29UTC"
servers:
  - url: {"Fn::Sub": "https://{restapi-id}.execute-api.${AWS::Region}.amazonaws.com/{stageName}"}
    variables:
      restapi-id:
        default: "xxxxxx"
      stageName:
        default: "live"
paths:
  /:
    options:
      summary: CORS support
      description: |
        Enable CORS by returning correct headers
      responses:
        "200":
          description: Default response for CORS method
          headers:
            Access-Control-Allow-Origin:
              schema:
                type: string
            Access-Control-Allow-Methods:
              schema:
                type: string
            Access-Control-Allow-Headers:
              schema:
                type: string
          content: {}
      x-amazon-apigateway-integration:
        type: mock
        requestTemplates:
          application/json: |
            {
              "statusCode" : 200
            }
        responses:
          default:
            statusCode: "200"
            responseParameters:
              method.response.header.Access-Control-Allow-Headers: '''Content-Type,X-Amz-Date,Authorization,X-Api-Key'''
              method.response.header.Access-Control-Allow-Methods: '''*'''
              method.response.header.Access-Control-Allow-Origin: '''*'''
            responseTemplates:
              application/json: |
                {}
    post:
      responses:
        "200":
          description: "200 response"
          headers:
            Access-Control-Allow-Origin:
              type: "string"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Empty"
      x-amazon-apigateway-integration:
        type: "aws"
        uri: {"Fn::Sub": "arn:${AWS::Partition}:apigateway:${AWS::Region}:states:action/StartSyncExecution"}
        httpMethod: "POST"
        passthroughBehavior: "when_no_templates"
        timeoutInMillis: 10000
        credentials:
          Fn::GetAtt: [SkeletonRestApiRole, Arn]
        requestTemplates:
          application/json:
            Fn::Sub: |-
              {
                "input": "$util.escapeJavaScript($input.json('$'))",
                "name": "$context.requestId",
                "stateMachineArn": "${SkeletonStateMachine}"
              }
        responses:
          default:
            statusCode: "200"
            responseParameters:
              method.response.header.Access-Control-Allow-Origin: '''*'''
            responseTemplates:
              application/json: |-
                $util.parseJson($input.json('output'))

components:
  schemas:
    Empty:
      title: "Empty Schema"
      type: "object"