swagger3 project.yml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  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. $ref: '#/components/schemas/User'
  270. 401:
  271. $ref: '#/components/responses/UnauthorizedError'
  272. security:
  273. - basicAuth: []
  274. post:
  275. tags:
  276. - users
  277. summary: add user
  278. description: add new user
  279. operationId: AddUser
  280. requestBody:
  281. description: User object
  282. required: true
  283. content:
  284. application/json:
  285. schema:
  286. type: object
  287. properties:
  288. username:
  289. type: string
  290. example: abi
  291. password:
  292. type: string
  293. example: abi123
  294. name:
  295. type: string
  296. example: abidzar
  297. responses:
  298. 201:
  299. description: record successfully added
  300. content:
  301. application/json:
  302. schema:
  303. $ref: '#/components/schemas/User'
  304. 400:
  305. $ref: '#/components/responses/400'
  306. 401:
  307. $ref: '#/components/responses/UnauthorizedError'
  308. 409:
  309. $ref: '#/components/responses/409'
  310. 413:
  311. $ref: '#/components/responses/413'
  312. security:
  313. - basicAuth: []
  314. /users/{userId}:
  315. get:
  316. tags:
  317. - users
  318. summary: find user by userId
  319. description: return user by userId
  320. operationId: getUserById
  321. parameters:
  322. - $ref: '#/components/parameters/UserPath'
  323. responses:
  324. 200:
  325. description: successful operation
  326. content:
  327. application/json:
  328. schema:
  329. $ref: '#/components/schemas/User'
  330. 401:
  331. $ref: '#/components/responses/UnauthorizedError'
  332. 404:
  333. $ref: '#/components/responses/404'
  334. security:
  335. - basicAuth: []
  336. put:
  337. tags:
  338. - users
  339. summary: update existing user except password
  340. description: update user
  341. operationId: updateUserById
  342. parameters:
  343. - $ref: '#/components/parameters/UserPath'
  344. requestBody:
  345. description: User object
  346. required: true
  347. content:
  348. application/json:
  349. schema:
  350. type: object
  351. properties:
  352. username:
  353. type: string
  354. example: abi
  355. name:
  356. type: string
  357. example: abidzar
  358. responses:
  359. 200:
  360. description: successful operation
  361. content:
  362. application/json:
  363. schema:
  364. $ref: '#/components/schemas/User'
  365. 400:
  366. $ref: '#/components/responses/400'
  367. 401:
  368. $ref: '#/components/responses/UnauthorizedError'
  369. 404:
  370. $ref: '#/components/responses/404'
  371. 409:
  372. $ref: '#/components/responses/409'
  373. 413:
  374. $ref: '#/components/responses/413'
  375. security:
  376. - basicAuth: []
  377. delete:
  378. tags:
  379. - users
  380. summary: deletes a user by ID
  381. description: delete a user by ID
  382. operationId: deleteUserById
  383. parameters:
  384. - $ref: '#/components/parameters/UserPath'
  385. responses:
  386. 200:
  387. description: successful operation
  388. 401:
  389. $ref: '#/components/responses/UnauthorizedError'
  390. 404:
  391. $ref: '#/components/responses/404'
  392. security:
  393. - basicAuth: []
  394. /users/{userId}/password:
  395. put:
  396. tags:
  397. - users
  398. summary: change password
  399. description: update user password
  400. operationId: updatePassword
  401. parameters:
  402. - $ref: '#/components/parameters/UserPath'
  403. requestBody:
  404. description: User object
  405. required: true
  406. content:
  407. application/json:
  408. schema:
  409. type: object
  410. properties:
  411. oldPassword:
  412. type: string
  413. example: abi123
  414. newPassword:
  415. type: string
  416. example: abi456
  417. responses:
  418. 200:
  419. description: successful operation
  420. content:
  421. application/json:
  422. schema:
  423. $ref: '#/components/schemas/User'
  424. 400:
  425. $ref: '#/components/responses/400'
  426. 401:
  427. $ref: '#/components/responses/UnauthorizedError'
  428. 403:
  429. description: wrong old password
  430. 404:
  431. $ref: '#/components/responses/404'
  432. security:
  433. - basicAuth: []
  434. components:
  435. schemas:
  436. Project:
  437. required:
  438. - id
  439. - name
  440. type: object
  441. properties:
  442. id:
  443. type: integer
  444. uniqueItems: true
  445. example: 2
  446. name:
  447. type: string
  448. uniqueItems: true
  449. maximum: 100
  450. example: PI
  451. description:
  452. type: string
  453. maximum: 255
  454. example: PropInspector
  455. Platform:
  456. type: object
  457. required:
  458. - id
  459. - name
  460. properties:
  461. id:
  462. type: integer
  463. uniqueItems: true
  464. example: 3
  465. name:
  466. type: string
  467. uniqueItems: true
  468. maximum: 100
  469. example: mobile
  470. project_id:
  471. $ref: '#/components/schemas/Project'
  472. User:
  473. type: object
  474. required:
  475. - id
  476. - username
  477. - password
  478. - name
  479. properties:
  480. id:
  481. type: integer
  482. uniqueItems: true
  483. example: 4
  484. username:
  485. type: string
  486. uniqueItems: true
  487. maximum: 100
  488. example: abi
  489. password:
  490. type: string
  491. maximum: 100
  492. example: abi123
  493. name:
  494. type: string
  495. maximum: 255
  496. example: abidzar
  497. parameters:
  498. projectPath:
  499. name: projectId
  500. in: path
  501. description: Project ID
  502. required: true
  503. schema:
  504. type: integer
  505. platformPath:
  506. name: platformId
  507. in: path
  508. description: Platform ID
  509. required: true
  510. schema:
  511. type: integer
  512. UserPath:
  513. name: userId
  514. in: path
  515. description: User ID
  516. required: true
  517. schema:
  518. type: integer
  519. projectQuery:
  520. name: project
  521. in: query
  522. description: Project ID
  523. schema:
  524. type: integer
  525. responses:
  526. 200SP:
  527. description: successful operation
  528. content:
  529. application/json:
  530. schema:
  531. $ref: '#/components/schemas/Project'
  532. 200AP:
  533. description: successful operation
  534. content:
  535. application/json:
  536. schema:
  537. type: array
  538. items:
  539. $ref: '#/components/schemas/Project'
  540. 201:
  541. description: Record Successfully added
  542. content:
  543. application/json:
  544. schema:
  545. $ref: '#/components/schemas/Project'
  546. 400:
  547. description: invalid data
  548. UnauthorizedError:
  549. description: Authentication information is missing or invalid
  550. headers:
  551. WWW_Authenticate:
  552. schema:
  553. type: string
  554. 404:
  555. description: not found
  556. 409:
  557. description: duplicate data
  558. 413:
  559. description: content too large
  560. requestBodies:
  561. Project:
  562. description: Project object
  563. required: true
  564. content:
  565. application/json:
  566. schema:
  567. type: object
  568. properties:
  569. name:
  570. type: string
  571. example: TM
  572. description:
  573. type: string
  574. example: TelMesengger
  575. Platform:
  576. description: Platform object
  577. required: true
  578. content:
  579. application/json:
  580. schema:
  581. type: object
  582. properties:
  583. name:
  584. type: string
  585. example: mobile
  586. project_id:
  587. $ref: '#/components/schemas/Project'
  588. securitySchemes:
  589. basicAuth:
  590. type: http
  591. scheme: basic
  592. description: Use `user` / `password` as the test credentials