Skip to content

Commit

Permalink
feat: add /render api via openapi spec
Browse files Browse the repository at this point in the history
  • Loading branch information
chizmw committed Oct 9, 2023
1 parent c0a6e5f commit ddb4fe7
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
77 changes: 77 additions & 0 deletions openapi/arcanescripts-oas3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
openapi: 3.0.0
info:
title: Arcane Scripts API
description: API for requesting and retrieving rendered scripts
version: v0.3.4

paths:
/render:
post:
description: Render a PDF from a script JSON object
parameters: []
responses:
200:
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/ScriptResponse'
500:
description: Internal Server Error
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/ScriptTopLevelResponse'
x-amazon-apigateway-integration:
uri: ${post_lambda_arn}
passthroughBehavior: when_no_match
httpMethod: POST
type: aws_proxy

components:
schemas:
# types
RequestId:
type: string
nullable: false
example: 057a3874-625a-41f0-a89a-50799e535f44

Status:
type: string
nullable: false
enum: [received, processing, complete, failed]
example: processing

DownloadURL:
type: string
nullable: true
example: https://somewhere.in.aws/b4f7-4d4acce98986.pdf

# responses

ScriptResponse:
type: object
properties:
request_id:
$ref: '#/components/schemas/RequestId'
status:
$ref: '#/components/schemas/Status'
download_url:
$ref: '#/components/schemas/DownloadURL'

ScriptTopLevelResponse:
type: object
properties:
message:
type: string
nullable: false
example: we didn't write this yet
request_id:
$ref: '#/components/schemas/RequestId'
status:
$ref: '#/components/schemas/Status'
23 changes: 23 additions & 0 deletions terraform/openapi.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
resource "aws_api_gateway_rest_api" "arcanescripts-api-gateway" {
name = "arcane-scripts-api"
description = "API for arcane-scripts.net"
body = data.template_file.arcanescripts_api_oas3.rendered
}

data "template_file" "arcanescripts_api_oas3" {
template = file("../openapi/arcanescripts-oas3.yaml")

vars = {
get_lambda_arn = module.lambda_function_api-status.lambda_function_invoke_arn
post_lambda_arn = module.lambda_function_api-status.lambda_function_invoke_arn
}
}

resource "aws_api_gateway_deployment" "arcanescripts-api-gateway-deployment" {
rest_api_id = aws_api_gateway_rest_api.arcanescripts-api-gateway.id
stage_name = "dev"
}

output "url" {
value = "${aws_api_gateway_deployment.arcanescripts-api-gateway-deployment.invoke_url}/api"
}

0 comments on commit ddb4fe7

Please sign in to comment.