-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add /render api via openapi spec
- Loading branch information
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |