-
Notifications
You must be signed in to change notification settings - Fork 0
/
openapi.yaml
210 lines (196 loc) · 5.85 KB
/
openapi.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
openapi: 3.0.1
info:
title: Template API Spec
description: APIs for the template example
version: "1.0"
servers:
- url: https://development.template_server.com
description: Server endpoint
tags:
- name: DateTime
description: DateTime related endpoints
- name: Operations
description: Operations related endpoints
components:
securitySchemes:
sigv4:
type: apiKey
name: Authorization
in: header
x-amazon-apigateway-authtype: awsSigv4
description: IAM access. Used by internal infrastructure, like lambdas
userPoolAuthorizer:
type: apiKey
name: Authorization
in: header
x-amazon-apigateway-authtype: cognito_user_pools
x-amazon-apigateway-authorizer:
type: cognito_user_pools
providerARNs:
- "${USERPOOL_ARN}"
# Unfortunately, only supported on httpApiGw and not on restApiGw (https://github.com/awsdocs/amazon-api-gateway-developer-guide/issues/65). Hail code duplication...
# x-amazon-apigateway-integrations:
# lambda:
# type: aws_proxy
# httpMethod: POST
# uri: "${LAMBDA_INVOCATION_URI}"
# passthroughBehavior: "when_no_match"
requestBodies:
operationsRequest:
description: The request body for an operation call
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/operationsRequestSchema'
responses:
iamRequired:
description: IAM auth is required for this operation
headers:
Content-Language:
schema:
type: string
example: en-US
content:
application/problem+json:
schema:
type: object
properties:
title:
type: string
default: 'IAM auth is required'
status:
type: number
default: 403
example:
title: IAM auth is required
status: 403
operationsResponse:
description: The response of an operation call
content:
application/json:
schema:
type: object
required:
- result
properties:
result:
type: number
format: double
description: The result of the operation
success:
description: Operation has completed successfully
schemas:
operationsRequestSchema:
type: object
required:
- first
- second
properties:
first:
type: number
format: double
description: the first number
second:
type: number
format: double
description: the second number
paths:
/datetime:
get:
operationId: get_datetime
tags:
- DateTime
description: Retrieves the api current date time
security: [] # No Security, anyone can call
responses:
'200':
description: Operation has completed successfully
content:
application/json:
schema:
type: object
properties:
result:
type: string
format: date-time
readOnly: true
x-amazon-apigateway-integration:
type: aws_proxy
httpMethod: POST
uri: "${LAMBDA_INVOCATION_URI}"
passthroughBehavior: "when_no_match"
/addition:
post:
operationId: post_addition
tags:
- Operations
description: Calculates the addition of 2 numbers
security:
- userPoolAuthorizer: ["openid", "profile"] # if scopes are provided, it expects the authtoken, otherwise the idtoken -- https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-enable-cognito-user-pool.html (point 5)
requestBody:
$ref: '#/components/requestBodies/operationsRequest'
responses:
'200':
$ref: '#/components/responses/operationsResponse'
x-amazon-apigateway-integration:
type: aws_proxy
httpMethod: POST
uri: "${LAMBDA_INVOCATION_URI}"
passthroughBehavior: "when_no_match"
/subtraction:
post:
operationId: post_subtraction
tags:
- Operations
description: Calculates the subtraction of 2 numbers
security:
- userPoolAuthorizer: ["openid", "profile"]
requestBody:
$ref: '#/components/requestBodies/operationsRequest'
responses:
'200':
$ref: '#/components/responses/operationsResponse'
x-amazon-apigateway-integration:
type: aws_proxy
httpMethod: POST
uri: "${LAMBDA_INVOCATION_URI}"
passthroughBehavior: "when_no_match"
/multiplication:
post:
operationId: post_multiplication
tags:
- Operations
description: Calculates the multiplication of 2 numbers
security:
- userPoolAuthorizer: ["openid", "profile"]
requestBody:
$ref: '#/components/requestBodies/operationsRequest'
responses:
'200':
$ref: '#/components/responses/operationsResponse'
x-amazon-apigateway-integration:
type: aws_proxy
httpMethod: POST
uri: "${LAMBDA_INVOCATION_URI}"
passthroughBehavior: "when_no_match"
/division:
post:
operationId: post_division
tags:
- Operations
description: Calculates the division of 2 numbers
security:
- sigv4: []
requestBody:
$ref: '#/components/requestBodies/operationsRequest'
responses:
'200':
$ref: '#/components/responses/operationsResponse'
'403':
$ref: '#/components/responses/iamRequired'
x-amazon-apigateway-integration:
type: aws_proxy
httpMethod: POST
uri: "${LAMBDA_INVOCATION_URI}"
passthroughBehavior: "when_no_match"