/backend/swagger/api.yaml

https://github.com/awslabs/realworld-serverless-application · YAML · 424 lines · 419 code · 3 blank · 2 comment · 0 complexity · c8f5652ed569eef2d7594f49371e01b4 MD5 · raw file

  1. openapi: 3.0.0
  2. info:
  3. title:
  4. Fn::Sub: realworld-serverless-application-backend-${Stage}
  5. description: A simplified implementation of AWS Serverless Application Repository
  6. version: 2019-10-13
  7. # Enable request validator. See doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-request-validation-sample-api-swagger.html
  8. x-amazon-apigateway-request-validators:
  9. all:
  10. validateRequestBody: true
  11. validateRequestParameters: true
  12. x-amazon-apigateway-request-validator: all
  13. x-amazon-apigateway-gateway-responses:
  14. # Provide more detailed error message for bad request body errors. See doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-gateway-responses.html
  15. BAD_REQUEST_BODY:
  16. responseTemplates:
  17. application/json: '{"errorCode": "BadRequestBody", "message": "$context.error.validationErrorString"}'
  18. responseParameters:
  19. gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
  20. DEFAULT_4XX:
  21. responseParameters:
  22. gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
  23. DEFAULT_5XX:
  24. responseParameters:
  25. gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
  26. paths:
  27. /applications:
  28. post:
  29. operationId: CreateApplication
  30. requestBody:
  31. content:
  32. application/json:
  33. schema:
  34. $ref: "#/components/schemas/CreateApplicationInput"
  35. required: true
  36. responses:
  37. "201":
  38. description: "Successfully Created an application."
  39. content:
  40. application/json:
  41. schema:
  42. $ref: "#/components/schemas/Application"
  43. "400":
  44. description: "Bad Request Exception"
  45. content:
  46. application/json:
  47. schema:
  48. $ref: "#/components/schemas/BadRequestException"
  49. "401":
  50. description: "Unauthorized Exception"
  51. content:
  52. application/json:
  53. schema:
  54. $ref: "#/components/schemas/UnauthorizedException"
  55. "409":
  56. description: "Conflict Exception"
  57. content:
  58. application/json:
  59. schema:
  60. $ref: "#/components/schemas/ConflictException"
  61. "429":
  62. description: "Too Many Requests Exception"
  63. content:
  64. application/json:
  65. schema:
  66. $ref: "#/components/schemas/TooManyRequestsException"
  67. "500":
  68. description: "Internal Server Error"
  69. content:
  70. application/json:
  71. schema:
  72. $ref: "#/components/schemas/InternalServerErrorException"
  73. x-amazon-apigateway-integration:
  74. uri:
  75. Fn::Sub: arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ApiLambda.Arn}:live/invocations
  76. httpMethod: POST
  77. type: aws_proxy
  78. passthroughBehavior: never
  79. security:
  80. - cognitoAuthorizer: []
  81. get:
  82. operationId: ListApplications
  83. parameters:
  84. - name: nextToken
  85. in: query
  86. required: false
  87. schema:
  88. type: string
  89. - name: maxItems
  90. in: query
  91. required: false
  92. schema:
  93. type: integer
  94. minimum: 1
  95. maximum: 100
  96. responses:
  97. "200":
  98. description: "Successfully list applications"
  99. content:
  100. application/json:
  101. schema:
  102. $ref: "#/components/schemas/ApplicationList"
  103. "400":
  104. description: "Bad Request Exception"
  105. content:
  106. application/json:
  107. schema:
  108. $ref: "#/components/schemas/BadRequestException"
  109. "401":
  110. description: "Unauthorized Exception"
  111. content:
  112. application/json:
  113. schema:
  114. $ref: "#/components/schemas/UnauthorizedException"
  115. "429":
  116. description: "Too Many Requests Exception"
  117. content:
  118. application/json:
  119. schema:
  120. $ref: "#/components/schemas/TooManyRequestsException"
  121. "500":
  122. description: "Internal Server Error"
  123. content:
  124. application/json:
  125. schema:
  126. $ref: "#/components/schemas/InternalServerErrorException"
  127. x-amazon-apigateway-integration:
  128. uri:
  129. Fn::Sub: arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ApiLambda.Arn}:live/invocations
  130. httpMethod: POST
  131. type: aws_proxy
  132. passthroughBehavior: never
  133. security:
  134. - cognitoAuthorizer: []
  135. "/applications/{applicationId}":
  136. get:
  137. operationId: GetApplication
  138. parameters:
  139. - name: applicationId
  140. in: path
  141. required: true
  142. schema:
  143. type: string
  144. pattern: ^[a-zA-Z0-9\-]{3,128}$
  145. responses:
  146. "200":
  147. description: "Successfully get an application"
  148. content:
  149. application/json:
  150. schema:
  151. $ref: "#/components/schemas/Application"
  152. "400":
  153. description: "Bad Request Exception"
  154. content:
  155. application/json:
  156. schema:
  157. $ref: "#/components/schemas/BadRequestException"
  158. "401":
  159. description: "Unauthorized Exception"
  160. content:
  161. application/json:
  162. schema:
  163. $ref: "#/components/schemas/UnauthorizedException"
  164. "404":
  165. description: "Not Found Exception"
  166. content:
  167. application/json:
  168. schema:
  169. $ref: "#/components/schemas/NotFoundException"
  170. "429":
  171. description: "Too Many Requests Exception"
  172. content:
  173. application/json:
  174. schema:
  175. $ref: "#/components/schemas/TooManyRequestsException"
  176. "500":
  177. description: "Internal Server Error"
  178. content:
  179. application/json:
  180. schema:
  181. $ref: "#/components/schemas/InternalServerErrorException"
  182. x-amazon-apigateway-integration:
  183. uri:
  184. Fn::Sub: arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ApiLambda.Arn}:live/invocations
  185. httpMethod: POST
  186. type: aws_proxy
  187. passthroughBehavior: never
  188. security:
  189. - cognitoAuthorizer: []
  190. patch:
  191. operationId: UpdateApplication
  192. parameters:
  193. - name: applicationId
  194. in: path
  195. required: true
  196. schema:
  197. type: string
  198. pattern: ^[a-zA-Z0-9\-]{3,128}$
  199. requestBody:
  200. content:
  201. application/json:
  202. schema:
  203. $ref: "#/components/schemas/UpdateApplicationInput"
  204. required: true
  205. responses:
  206. "200":
  207. description: "Successfully update an application"
  208. content:
  209. application/json:
  210. schema:
  211. $ref: "#/components/schemas/Application"
  212. "400":
  213. description: "Bad Request Exception"
  214. content:
  215. application/json:
  216. schema:
  217. $ref: "#/components/schemas/BadRequestException"
  218. "401":
  219. description: "Unauthorized Exception"
  220. content:
  221. application/json:
  222. schema:
  223. $ref: "#/components/schemas/UnauthorizedException"
  224. "404":
  225. description: "Not Found Exception"
  226. content:
  227. application/json:
  228. schema:
  229. $ref: "#/components/schemas/NotFoundException"
  230. "429":
  231. description: "Too Many Requests Exception"
  232. content:
  233. application/json:
  234. schema:
  235. $ref: "#/components/schemas/TooManyRequestsException"
  236. "500":
  237. description: "Internal Server Error"
  238. content:
  239. application/json:
  240. schema:
  241. $ref: "#/components/schemas/InternalServerErrorException"
  242. x-amazon-apigateway-integration:
  243. uri:
  244. Fn::Sub: arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ApiLambda.Arn}:live/invocations
  245. httpMethod: POST
  246. type: aws_proxy
  247. passthroughBehavior: never
  248. security:
  249. - cognitoAuthorizer: []
  250. delete:
  251. operationId: DeleteApplication
  252. parameters:
  253. - name: applicationId
  254. in: path
  255. required: true
  256. schema:
  257. type: string
  258. pattern: ^[a-zA-Z0-9\-]{3,128}$
  259. responses:
  260. "204":
  261. description: "Successfully delete an application"
  262. "400":
  263. description: "Bad Request Exception"
  264. content:
  265. application/json:
  266. schema:
  267. $ref: "#/components/schemas/BadRequestException"
  268. "401":
  269. description: "Unauthorized Exception"
  270. content:
  271. application/json:
  272. schema:
  273. $ref: "#/components/schemas/UnauthorizedException"
  274. "404":
  275. description: "Not Found Exception"
  276. content:
  277. application/json:
  278. schema:
  279. $ref: "#/components/schemas/NotFoundException"
  280. "429":
  281. description: "Too Many Requests Exception"
  282. content:
  283. application/json:
  284. schema:
  285. $ref: "#/components/schemas/TooManyRequestsException"
  286. "500":
  287. description: "Internal Server Error"
  288. content:
  289. application/json:
  290. schema:
  291. $ref: "#/components/schemas/InternalServerErrorException"
  292. x-amazon-apigateway-integration:
  293. uri:
  294. Fn::Sub: arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ApiLambda.Arn}:live/invocations
  295. httpMethod: POST
  296. type: aws_proxy
  297. passthroughBehavior: never
  298. security:
  299. - cognitoAuthorizer: []
  300. components:
  301. securitySchemes:
  302. cognitoAuthorizer:
  303. type: apiKey
  304. name: Authorization
  305. in: header
  306. x-amazon-apigateway-authtype: cognito_user_pools
  307. x-amazon-apigateway-authorizer:
  308. providerARNs:
  309. - Fn::GetAtt: ApplicationsApiUserPool.Arn
  310. type: cognito_user_pools
  311. schemas:
  312. BadRequestException:
  313. type: object
  314. properties:
  315. message:
  316. type: string
  317. errorCode:
  318. type: string
  319. UnauthorizedException:
  320. type: object
  321. properties:
  322. message:
  323. type: string
  324. errorCode:
  325. type: string
  326. NotFoundException:
  327. type: object
  328. properties:
  329. message:
  330. type: string
  331. errorCode:
  332. type: string
  333. ConflictException:
  334. type: object
  335. properties:
  336. message:
  337. type: string
  338. errorCode:
  339. type: string
  340. TooManyRequestsException:
  341. type: object
  342. properties:
  343. message:
  344. type: string
  345. errorCode:
  346. type: string
  347. InternalServerErrorException:
  348. type: object
  349. properties:
  350. message:
  351. type: string
  352. errorCode:
  353. type: string
  354. CreateApplicationInput:
  355. type: object
  356. required:
  357. - applicationId
  358. - description
  359. - author
  360. properties:
  361. applicationId:
  362. type: string
  363. pattern: ^[a-zA-Z0-9\-]{3,128}$
  364. description:
  365. type: string
  366. minLength: 3
  367. maxLength: 256
  368. author:
  369. type: string
  370. pattern: ^[a-zA-Z0-9\-]{1,128}$
  371. homePageUrl:
  372. type: string
  373. pattern: ^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$
  374. UpdateApplicationInput:
  375. type: object
  376. properties:
  377. description:
  378. type: string
  379. minLength: 3
  380. maxLength: 256
  381. author:
  382. type: string
  383. pattern: ^[a-zA-Z0-9\-]{1,128}$
  384. homePageUrl:
  385. type: string
  386. pattern: ^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$
  387. Application:
  388. type: object
  389. required:
  390. - applicationId
  391. - description
  392. - author
  393. properties:
  394. applicationId:
  395. type: string
  396. description:
  397. type: string
  398. author:
  399. type: string
  400. creationTime:
  401. type: string
  402. homePageUrl:
  403. type: string
  404. ApplicationSummary:
  405. type: object
  406. properties:
  407. applicationId:
  408. type: string
  409. description:
  410. type: string
  411. creationTime:
  412. type: string
  413. ApplicationList:
  414. type: object
  415. properties:
  416. applications:
  417. type: array
  418. items:
  419. $ref: "#/components/schemas/ApplicationSummary"
  420. nextToken:
  421. type: string