swagger3 project.yml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. openapi: 3.0.1
  2. info:
  3. title: Project API
  4. description: Latihan Project API
  5. version: 3.0.0
  6. servers:
  7. - url: http://localhost:8080/api/v1
  8. tags:
  9. - name: projects
  10. description: everything project
  11. - name: platforms
  12. description: everything platform
  13. - name: users
  14. description: everything user
  15. paths:
  16. /projects:
  17. get:
  18. tags:
  19. - projects
  20. summary: find all project
  21. description: return all project
  22. operationId: getProject
  23. responses:
  24. 200:
  25. $ref: '#/components/responses/200AP'
  26. 401:
  27. $ref: '#/components/responses/UnauthorizedError'
  28. security:
  29. - basicAuth: []
  30. post:
  31. tags:
  32. - projects
  33. summary: Add new Project
  34. description: Add new Project
  35. operationId: addProject
  36. requestBody:
  37. $ref: '#/components/requestBodies/Project'
  38. responses:
  39. 201:
  40. $ref: '#/components/responses/201'
  41. 400:
  42. $ref: '#/components/responses/400'
  43. 401:
  44. $ref: '#/components/responses/UnauthorizedError'
  45. 409:
  46. $ref: '#/components/responses/409'
  47. 413:
  48. $ref: '#/components/responses/413'
  49. security:
  50. - basicAuth: []
  51. /projects/{projectId}:
  52. get:
  53. tags:
  54. - projects
  55. summary: find project by ID
  56. description: return project
  57. operationId: getProjectById
  58. parameters:
  59. - $ref: '#/components/parameters/projectPath'
  60. responses:
  61. 200:
  62. $ref: '#/components/responses/200SP'
  63. 401:
  64. $ref: '#/components/responses/UnauthorizedError'
  65. 404:
  66. $ref: '#/components/responses/404'
  67. security:
  68. - basicAuth: []
  69. put:
  70. tags:
  71. - projects
  72. summary: update existing project by ID
  73. description: update project
  74. operationId: updateProjectById
  75. parameters:
  76. - $ref: '#/components/parameters/projectPath'
  77. requestBody:
  78. $ref: '#/components/requestBodies/Project'
  79. responses:
  80. 200:
  81. $ref: '#/components/responses/200AP'
  82. 400:
  83. $ref: '#/components/responses/400'
  84. 401:
  85. $ref: '#/components/responses/UnauthorizedError'
  86. 404:
  87. $ref: '#/components/responses/404'
  88. 409:
  89. $ref: '#/components/responses/409'
  90. 413:
  91. $ref: '#/components/responses/413'
  92. security:
  93. - basicAuth: []
  94. delete:
  95. tags:
  96. - projects
  97. summary: Deletes a project
  98. description: delete a project
  99. operationId: deleteProject
  100. parameters:
  101. - $ref: '#/components/parameters/projectPath'
  102. responses:
  103. 200:
  104. description: successful operation
  105. 205:
  106. description: Unable to delete. Data is used.
  107. 401:
  108. $ref: '#/components/responses/UnauthorizedError'
  109. 404:
  110. $ref: '#/components/responses/404'
  111. security:
  112. - basicAuth: []
  113. /platforms:
  114. get:
  115. tags:
  116. - platforms
  117. summary: find all platform of a project
  118. description: return all platform of a project
  119. operationId: getPlatformByProjectId
  120. parameters:
  121. - $ref: '#/components/parameters/projectQuery'
  122. responses:
  123. 200:
  124. description: successful operation
  125. content:
  126. application/json:
  127. schema:
  128. type: array
  129. items:
  130. $ref: '#/components/schemas/Platform'
  131. 401:
  132. $ref: '#/components/responses/UnauthorizedError'
  133. security:
  134. - basicAuth: []
  135. post:
  136. tags:
  137. - platforms
  138. summary: Add new platform for a project
  139. description: add new platform for a project
  140. operationId: addPlatformByProjectId
  141. requestBody:
  142. description: Platform object
  143. required: true
  144. content:
  145. application/json:
  146. schema:
  147. type: object
  148. properties:
  149. name:
  150. type: string
  151. example: web
  152. project_id:
  153. type: integer
  154. example: 1
  155. responses:
  156. 201:
  157. description: record successfully added
  158. content:
  159. application/json:
  160. schema:
  161. $ref: '#/components/schemas/Platform'
  162. 400:
  163. $ref: '#/components/responses/400'
  164. 401:
  165. $ref: '#/components/responses/UnauthorizedError'
  166. 404:
  167. $ref: '#/components/responses/404'
  168. 409:
  169. $ref: '#/components/responses/409'
  170. 413:
  171. $ref: '#/components/responses/413'
  172. security:
  173. - basicAuth: []
  174. /platforms/{platformId}:
  175. get:
  176. tags:
  177. - platforms
  178. summary: find platform by ID
  179. description: return platform by ID
  180. operationId: getPlatformById
  181. parameters:
  182. - $ref: '#/components/parameters/platformPath'
  183. responses:
  184. 200:
  185. description: successful operation
  186. content:
  187. application/json:
  188. schema:
  189. $ref: '#/components/schemas/Platform'
  190. 401:
  191. $ref: '#/components/responses/UnauthorizedError'
  192. 404:
  193. $ref: '#/components/responses/404'
  194. security:
  195. - basicAuth: []
  196. put:
  197. tags:
  198. - platforms
  199. summary: update existing platform by ID
  200. description: update platform
  201. operationId: updatePlatformById
  202. parameters:
  203. - $ref: '#/components/parameters/platformPath'
  204. requestBody:
  205. description: Platform object
  206. required: true
  207. content:
  208. application/json:
  209. schema:
  210. type: object
  211. properties:
  212. name:
  213. type: string
  214. example: web
  215. project_id:
  216. type: integer
  217. example: 1
  218. responses:
  219. 200:
  220. description: successful operation
  221. content:
  222. application/json:
  223. schema:
  224. $ref: '#/components/schemas/Platform'
  225. 400:
  226. $ref: '#/components/responses/400'
  227. 401:
  228. $ref: '#/components/responses/UnauthorizedError'
  229. 404:
  230. $ref: '#/components/responses/404'
  231. 409:
  232. $ref: '#/components/responses/409'
  233. 413:
  234. $ref: '#/components/responses/413'
  235. security:
  236. - basicAuth: []
  237. delete:
  238. tags:
  239. - platforms
  240. summary: deletes a platform by ID
  241. description: delete a platform by ID
  242. operationId: deletePlatformById
  243. parameters:
  244. - $ref: '#/components/parameters/platformPath'
  245. responses:
  246. 200:
  247. description: successful operation
  248. 401:
  249. $ref: '#/components/responses/UnauthorizedError'
  250. 404:
  251. $ref: '#/components/responses/404'
  252. security:
  253. - basicAuth: []
  254. /users:
  255. get:
  256. tags:
  257. - users
  258. summary: find all user
  259. description: return all user
  260. operationId: getUser
  261. responses:
  262. 200:
  263. description: successful operation
  264. content:
  265. application/json:
  266. schema:
  267. type: array
  268. items:
  269. properties:
  270. id:
  271. type: integer
  272. example: 1
  273. username:
  274. type: string
  275. example: abi
  276. name:
  277. type: string
  278. example: abidzar
  279. 401:
  280. $ref: '#/components/responses/UnauthorizedError'
  281. security:
  282. - basicAuth: []
  283. post:
  284. tags:
  285. - users
  286. summary: add user
  287. description: add new user
  288. operationId: AddUser
  289. requestBody:
  290. description: User object
  291. required: true
  292. content:
  293. application/json:
  294. schema:
  295. type: object
  296. properties:
  297. username:
  298. type: string
  299. example: abi
  300. password:
  301. type: string
  302. example: abi123
  303. name:
  304. type: string
  305. example: abidzar
  306. responses:
  307. 201:
  308. description: record successfully added
  309. content:
  310. application/json:
  311. schema:
  312. properties:
  313. id:
  314. type: integer
  315. example: 1
  316. username:
  317. type: string
  318. example: abi
  319. name:
  320. type: string
  321. example: abidzar
  322. 400:
  323. $ref: '#/components/responses/400'
  324. 401:
  325. $ref: '#/components/responses/UnauthorizedError'
  326. 409:
  327. $ref: '#/components/responses/409'
  328. 413:
  329. $ref: '#/components/responses/413'
  330. security:
  331. - basicAuth: []
  332. /users/{userId}:
  333. get:
  334. tags:
  335. - users
  336. summary: find user by userId
  337. description: return user by userId
  338. operationId: getUserById
  339. parameters:
  340. - $ref: '#/components/parameters/UserPath'
  341. responses:
  342. 200:
  343. description: successful operation
  344. content:
  345. application/json:
  346. schema:
  347. properties:
  348. id:
  349. type: integer
  350. example: 1
  351. username:
  352. type: string
  353. example: abi
  354. name:
  355. type: string
  356. example: abidzar
  357. 401:
  358. $ref: '#/components/responses/UnauthorizedError'
  359. 404:
  360. $ref: '#/components/responses/404'
  361. security:
  362. - basicAuth: []
  363. put:
  364. tags:
  365. - users
  366. summary: update existing user except password
  367. description: update user
  368. operationId: updateUserById
  369. parameters:
  370. - $ref: '#/components/parameters/UserPath'
  371. requestBody:
  372. description: User object
  373. required: true
  374. content:
  375. application/json:
  376. schema:
  377. type: object
  378. properties:
  379. username:
  380. type: string
  381. example: abi
  382. name:
  383. type: string
  384. example: abidzar
  385. responses:
  386. 200:
  387. description: successful operation
  388. content:
  389. application/json:
  390. schema:
  391. properties:
  392. id:
  393. type: integer
  394. example: 1
  395. username:
  396. type: string
  397. example: abi
  398. name:
  399. type: string
  400. example: abidzar
  401. 400:
  402. $ref: '#/components/responses/400'
  403. 401:
  404. $ref: '#/components/responses/UnauthorizedError'
  405. 404:
  406. $ref: '#/components/responses/404'
  407. 409:
  408. $ref: '#/components/responses/409'
  409. 413:
  410. $ref: '#/components/responses/413'
  411. security:
  412. - basicAuth: []
  413. delete:
  414. tags:
  415. - users
  416. summary: deletes a user by ID
  417. description: delete a user by ID
  418. operationId: deleteUserById
  419. parameters:
  420. - $ref: '#/components/parameters/UserPath'
  421. responses:
  422. 200:
  423. description: successful operation
  424. 401:
  425. $ref: '#/components/responses/UnauthorizedError'
  426. 404:
  427. $ref: '#/components/responses/404'
  428. security:
  429. - basicAuth: []
  430. /users/{userId}/password:
  431. put:
  432. tags:
  433. - users
  434. summary: change password
  435. description: update user password
  436. operationId: updatePassword
  437. parameters:
  438. - $ref: '#/components/parameters/UserPath'
  439. requestBody:
  440. description: User object
  441. required: true
  442. content:
  443. application/json:
  444. schema:
  445. type: object
  446. properties:
  447. oldPassword:
  448. type: string
  449. example: abi123
  450. newPassword:
  451. type: string
  452. example: abi456
  453. responses:
  454. 200:
  455. description: successful operation
  456. content:
  457. application/json:
  458. schema:
  459. properties:
  460. id:
  461. type: integer
  462. example: 1
  463. username:
  464. type: string
  465. example: abi
  466. name:
  467. type: string
  468. example: abidzar
  469. 400:
  470. $ref: '#/components/responses/400'
  471. 401:
  472. $ref: '#/components/responses/UnauthorizedError'
  473. 403:
  474. description: wrong old password
  475. 404:
  476. $ref: '#/components/responses/404'
  477. security:
  478. - basicAuth: []
  479. components:
  480. schemas:
  481. Project:
  482. required:
  483. - id
  484. - name
  485. type: object
  486. properties:
  487. id:
  488. type: integer
  489. uniqueItems: true
  490. example: 2
  491. name:
  492. type: string
  493. uniqueItems: true
  494. maximum: 100
  495. example: PI
  496. description:
  497. type: string
  498. maximum: 255
  499. example: PropInspector
  500. Platform:
  501. type: object
  502. required:
  503. - id
  504. - name
  505. properties:
  506. id:
  507. type: integer
  508. uniqueItems: true
  509. example: 3
  510. name:
  511. type: string
  512. uniqueItems: true
  513. maximum: 100
  514. example: mobile
  515. project_id:
  516. $ref: '#/components/schemas/Project'
  517. User:
  518. type: object
  519. required:
  520. - id
  521. - username
  522. - password
  523. - name
  524. properties:
  525. id:
  526. type: integer
  527. uniqueItems: true
  528. example: 4
  529. username:
  530. type: string
  531. uniqueItems: true
  532. maximum: 100
  533. example: abi
  534. password:
  535. type: string
  536. maximum: 100
  537. example: abi123
  538. name:
  539. type: string
  540. maximum: 255
  541. example: abidzar
  542. parameters:
  543. projectPath:
  544. name: projectId
  545. in: path
  546. description: Project ID
  547. required: true
  548. schema:
  549. type: integer
  550. platformPath:
  551. name: platformId
  552. in: path
  553. description: Platform ID
  554. required: true
  555. schema:
  556. type: integer
  557. UserPath:
  558. name: userId
  559. in: path
  560. description: User ID
  561. required: true
  562. schema:
  563. type: integer
  564. projectQuery:
  565. name: project
  566. in: query
  567. description: Project ID
  568. schema:
  569. type: integer
  570. responses:
  571. 200SP:
  572. description: successful operation
  573. content:
  574. application/json:
  575. schema:
  576. $ref: '#/components/schemas/Project'
  577. 200AP:
  578. description: successful operation
  579. content:
  580. application/json:
  581. schema:
  582. type: array
  583. items:
  584. $ref: '#/components/schemas/Project'
  585. 201:
  586. description: Record Successfully added
  587. content:
  588. application/json:
  589. schema:
  590. $ref: '#/components/schemas/Project'
  591. 400:
  592. description: invalid data
  593. UnauthorizedError:
  594. description: Authentication information is missing or invalid
  595. headers:
  596. WWW_Authenticate:
  597. schema:
  598. type: string
  599. 404:
  600. description: not found
  601. 409:
  602. description: duplicate data
  603. 413:
  604. description: content too large
  605. requestBodies:
  606. Project:
  607. description: Project object
  608. required: true
  609. content:
  610. application/json:
  611. schema:
  612. type: object
  613. properties:
  614. name:
  615. type: string
  616. example: TM
  617. description:
  618. type: string
  619. example: TelMesengger
  620. Platform:
  621. description: Platform object
  622. required: true
  623. content:
  624. application/json:
  625. schema:
  626. type: object
  627. properties:
  628. name:
  629. type: string
  630. example: mobile
  631. project_id:
  632. $ref: '#/components/schemas/Project'
  633. securitySchemes:
  634. basicAuth:
  635. type: http
  636. scheme: basic
  637. description: Use `user` / `password` as the test credentials