openapi: "3.0.1" info: title: "SolutionLanguageDetectionAndTranslationAPI" 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: | {} workflows: 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/StartExecution"} httpMethod: "POST" passthroughBehavior: "when_no_templates" timeoutInMillis: 10000 credentials: Fn::GetAtt: [SolutionRestApiRole, Arn] requestTemplates: application/json: Fn::Sub: |- { "input": "$util.escapeJavaScript($input.json('$'))", "name": "$context.requestId", "stateMachineArn": "arn:${AWS::Partition}:states:${AWS::Region}:${AWS::AccountId}:stateMachine:SolutionLanguageDetectionAndTranslationStateMachine" } responses: default: statusCode: "200" responseParameters: method.response.header.Access-Control-Allow-Origin: '''*''' responseTemplates: application/json: |- #set($inputRoot = $input.path('$')) { "workflow": { "executionArn": "$inputRoot.executionArn", "startDate": "$inputRoot.startDate" } } get: 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/ListExecutions"} httpMethod: "POST" passthroughBehavior: "when_no_templates" timeoutInMillis: 10000 credentials: Fn::GetAtt: [SolutionRestApiRole, Arn] requestTemplates: application/json: Fn::Sub: |- { "input": "$util.escapeJavaScript($input.json('$'))", "name": "$context.requestId", "stateMachineArn": "arn:${AWS::Partition}:states:${AWS::Region}:${AWS::AccountId}:stateMachine:SolutionLanguageDetectionAndTranslationStateMachine" } responses: default: statusCode: "200" responseParameters: method.response.header.Access-Control-Allow-Origin: '''*''' responseTemplates: application/json: |- #set($inputRoot = $input.path('$.executions')) { "workflows": [ #foreach($elem in $inputRoot) #set($stopDate = $elem.stopDate) { "status": "$elem.status", "executionArn": "$elem.executionArn", "startDate": "$elem.startDate"#if($stopDate && $stopDate != 0), "stopDate": "$elem.stopDate" #end }#if($foreach.hasNext),#end #end ] } workflows/{id}: get: 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/DescribeExecution"} httpMethod: "POST" passthroughBehavior: "when_no_templates" timeoutInMillis: 10000 credentials: Fn::GetAtt: [SolutionRestApiRole, Arn] requestTemplates: application/json: Fn::Sub: |- { "executionArn": "$input.params('id')" } responses: default: statusCode: "200" responseParameters: method.response.header.Access-Control-Allow-Origin: '''*''' responseTemplates: application/json: |- #set($inputRoot = $input.path('$')) { "workflow": { #set($stopDate = $inputRoot.stopDate) #set($status = $inputRoot.status) #set($output = $util.parseJson($inputRoot.output)) "status": "$status", "executionArn": "$inputRoot.executionArn", "startDate": "$inputRoot.startDate"#if($stopDate && $stopDate != 0), "stopDate": "$stopDate"#end#if($status && $status == 'SUCCEEDED'), "workflowDetails": { "sourceText": "$output.source.text", "sourceLanguageCode": "$output.source.languageCode", "targetText": "$output.target.text", "targetLanguageCode": "$output.target.languageCode" } #end } } delete: 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/StopExecution"} httpMethod: "POST" passthroughBehavior: "when_no_templates" timeoutInMillis: 10000 credentials: Fn::GetAtt: [SolutionRestApiRole, Arn] requestTemplates: application/json: Fn::Sub: |- { "executionArn": "$input.params('id')" } responses: default: statusCode: "200" responseParameters: method.response.header.Access-Control-Allow-Origin: '''*''' responseTemplates: application/json: |- #set($inputRoot = $input.path('$')) { "workflow": { "executionArn": "$input.params('id')", "stopDate": "$inputRoot.stopDate" } } respond/confirm/{proxy+}: get: 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/SendTaskSuccess"} httpMethod: "POST" passthroughBehavior: "when_no_templates" timeoutInMillis: 10000 credentials: Fn::GetAtt: [SolutionRestApiRole, Arn] requestTemplates: application/json: Fn::Sub: |- { "output": "{\"detection\": \"confirmed\"}", "taskToken": "$input.params('proxy')" } responses: default: statusCode: "200" responseParameters: method.response.header.Access-Control-Allow-Origin: '''*''' responseTemplates: application/json: |- {} respond/reject/{proxy+}: get: 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/SendTaskFailure"} httpMethod: "POST" passthroughBehavior: "when_no_templates" timeoutInMillis: 10000 credentials: Fn::GetAtt: [SolutionRestApiRole, Arn] requestTemplates: application/json: Fn::Sub: |- { "cause": "{\"detection\": \"rejected\"}", "taskToken": "$input.params('proxy')" } responses: default: statusCode: "200" responseParameters: method.response.header.Access-Control-Allow-Origin: '''*''' responseTemplates: application/json: |- {} components: schemas: Empty: title: "Empty Schema" type: "object"