swagger3 project.yml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919
  1. openapi: 3.0.1
  2. info:
  3. title: Project API
  4. description: |
  5. Latihan Project API
  6. - CRUD Project
  7. - Platform Relationship
  8. - Auth
  9. - Membership & Ownership
  10. version: 4.0.0
  11. servers:
  12. - url: http://localhost:8080/api/v1
  13. tags:
  14. - name: projects
  15. description: everything project
  16. - name: platforms
  17. description: everything platform
  18. - name: users
  19. description: everything user
  20. paths:
  21. /projects:
  22. get:
  23. tags:
  24. - projects
  25. summary: find all project
  26. description: return all project
  27. operationId: getProject
  28. responses:
  29. 200:
  30. $ref: '#/components/responses/getArrayProject'
  31. 401:
  32. $ref: '#/components/responses/UnauthorizedError'
  33. security:
  34. - testAuth: []
  35. post:
  36. tags:
  37. - projects
  38. summary: Add new Project
  39. description: Add new Project
  40. operationId: addProject
  41. requestBody:
  42. $ref: '#/components/requestBodies/Project'
  43. responses:
  44. 201:
  45. $ref: '#/components/responses/successAddProject'
  46. 400:
  47. $ref: '#/components/responses/400'
  48. 401:
  49. $ref: '#/components/responses/UnauthorizedError'
  50. 409:
  51. $ref: '#/components/responses/409'
  52. 413:
  53. $ref: '#/components/responses/413'
  54. security:
  55. - testAuth: []
  56. /projects/{projectId}:
  57. get:
  58. tags:
  59. - projects
  60. summary: find project by ID
  61. description: return project
  62. operationId: getProjectById
  63. parameters:
  64. - $ref: '#/components/parameters/projectPath'
  65. responses:
  66. 200:
  67. $ref: '#/components/responses/getSingleProject'
  68. 401:
  69. $ref: '#/components/responses/UnauthorizedError'
  70. 404:
  71. $ref: '#/components/responses/404'
  72. security:
  73. - testAuth: []
  74. put:
  75. tags:
  76. - projects
  77. summary: update existing project by ID
  78. description: update project
  79. operationId: updateProjectById
  80. parameters:
  81. - $ref: '#/components/parameters/projectPath'
  82. requestBody:
  83. $ref: '#/components/requestBodies/Project'
  84. responses:
  85. 200:
  86. $ref: '#/components/responses/getSingleProject'
  87. 400:
  88. $ref: '#/components/responses/400'
  89. 401:
  90. $ref: '#/components/responses/UnauthorizedError'
  91. 403:
  92. $ref: '#/components/responses/403'
  93. 409:
  94. $ref: '#/components/responses/409'
  95. 413:
  96. $ref: '#/components/responses/413'
  97. security:
  98. - testAuth: []
  99. delete:
  100. tags:
  101. - projects
  102. summary: Deletes a project
  103. description: delete a project
  104. operationId: deleteProject
  105. parameters:
  106. - $ref: '#/components/parameters/projectPath'
  107. responses:
  108. 200:
  109. description: successful operation
  110. 205:
  111. description: Unable to delete. Data is used.
  112. 401:
  113. $ref: '#/components/responses/UnauthorizedError'
  114. 403:
  115. $ref: '#/components/responses/403'
  116. security:
  117. - testAuth: []
  118. /projects/{projectId}/member:
  119. get:
  120. tags:
  121. - projects
  122. summary: find all member by project
  123. description: return all member by project
  124. operationId: getMemberByProject
  125. parameters:
  126. - $ref: '#/components/parameters/projectPath'
  127. responses:
  128. 200:
  129. $ref: '#/components/responses/getArrayMember'
  130. 401:
  131. $ref: '#/components/responses/UnauthorizedError'
  132. security:
  133. - testAuth: []
  134. post:
  135. tags:
  136. - projects
  137. summary: add project member
  138. description: add project member
  139. operationId: addProjectMember
  140. parameters:
  141. - $ref: '#/components/parameters/projectPath'
  142. requestBody:
  143. $ref: '#/components/requestBodies/ProjectMember'
  144. responses:
  145. 201:
  146. $ref: '#/components/responses/successAddMember'
  147. 400:
  148. $ref: '#/components/responses/400'
  149. 401:
  150. $ref: '#/components/responses/UnauthorizedError'
  151. 403:
  152. $ref: '#/components/responses/403'
  153. 404:
  154. $ref: '#/components/responses/404'
  155. 409:
  156. $ref: '#/components/responses/409'
  157. security:
  158. - testAuth: []
  159. /projects/member/{memberId}:
  160. get:
  161. tags:
  162. - projects
  163. summary: find member by ID
  164. description: return member by ID
  165. operationId: getMemberProject
  166. parameters:
  167. - $ref: '#/components/parameters/memberPath'
  168. responses:
  169. 200:
  170. $ref: '#/components/responses/getSingleMember'
  171. 401:
  172. $ref: '#/components/responses/UnauthorizedError'
  173. security:
  174. - testAuth: []
  175. delete:
  176. tags:
  177. - projects
  178. summary: delete project member
  179. description: delete project member
  180. operationId: deleteProjectMember
  181. parameters:
  182. - $ref: '#/components/parameters/memberPath'
  183. responses:
  184. 200:
  185. description: successful operation
  186. 401:
  187. $ref: '#/components/responses/UnauthorizedError'
  188. 403:
  189. $ref: '#/components/responses/403'
  190. 404:
  191. $ref: '#/components/responses/404'
  192. security:
  193. - testAuth: []
  194. /platforms:
  195. get:
  196. tags:
  197. - platforms
  198. summary: find all platform of a project
  199. description: return all platform of a project
  200. operationId: getPlatformByProjectId
  201. parameters:
  202. - $ref: '#/components/parameters/projectQuery'
  203. responses:
  204. 200:
  205. $ref: '#/components/responses/getArrayPlatform'
  206. 401:
  207. $ref: '#/components/responses/UnauthorizedError'
  208. security:
  209. - testAuth: []
  210. post:
  211. tags:
  212. - platforms
  213. summary: Add new platform for a project
  214. description: add new platform for a project
  215. operationId: addPlatformByProjectId
  216. requestBody:
  217. $ref: '#/components/requestBodies/Platform'
  218. responses:
  219. 201:
  220. $ref: '#/components/responses/successAddPlatform'
  221. 400:
  222. $ref: '#/components/responses/400'
  223. 401:
  224. $ref: '#/components/responses/UnauthorizedError'
  225. 403:
  226. $ref: '#/components/responses/403'
  227. 404:
  228. $ref: '#/components/responses/404'
  229. 409:
  230. $ref: '#/components/responses/409'
  231. 413:
  232. $ref: '#/components/responses/413'
  233. security:
  234. - testAuth: []
  235. /platforms/{platformId}:
  236. get:
  237. tags:
  238. - platforms
  239. summary: find platform by ID
  240. description: return platform by ID
  241. operationId: getPlatformById
  242. parameters:
  243. - $ref: '#/components/parameters/platformPath'
  244. responses:
  245. 200:
  246. $ref: '#/components/responses/getSinglePlatform'
  247. 401:
  248. $ref: '#/components/responses/UnauthorizedError'
  249. 404:
  250. $ref: '#/components/responses/404'
  251. security:
  252. - testAuth: []
  253. put:
  254. tags:
  255. - platforms
  256. summary: update existing platform by ID
  257. description: update platform
  258. operationId: updatePlatformById
  259. parameters:
  260. - $ref: '#/components/parameters/platformPath'
  261. requestBody:
  262. $ref: '#/components/requestBodies/Platform'
  263. responses:
  264. 200:
  265. $ref: '#/components/responses/getSinglePlatform'
  266. 400:
  267. $ref: '#/components/responses/400'
  268. 401:
  269. $ref: '#/components/responses/UnauthorizedError'
  270. 403:
  271. $ref: '#/components/responses/403'
  272. 404:
  273. $ref: '#/components/responses/404'
  274. 409:
  275. $ref: '#/components/responses/409'
  276. 413:
  277. $ref: '#/components/responses/413'
  278. security:
  279. - testAuth: []
  280. delete:
  281. tags:
  282. - platforms
  283. summary: deletes a platform by ID
  284. description: delete a platform by ID
  285. operationId: deletePlatformById
  286. parameters:
  287. - $ref: '#/components/parameters/platformPath'
  288. responses:
  289. 200:
  290. description: successful operation
  291. 401:
  292. $ref: '#/components/responses/UnauthorizedError'
  293. 403:
  294. $ref: '#/components/responses/403'
  295. 404:
  296. $ref: '#/components/responses/404'
  297. security:
  298. - testAuth: []
  299. /users:
  300. get:
  301. tags:
  302. - users
  303. summary: find all user
  304. description: return all user
  305. operationId: getUser
  306. responses:
  307. 200:
  308. $ref: '#/components/responses/getArrayUser'
  309. 401:
  310. $ref: '#/components/responses/UnauthorizedError'
  311. security:
  312. - testAuth: []
  313. post:
  314. tags:
  315. - users
  316. summary: add user
  317. description: add new user
  318. operationId: AddUser
  319. requestBody:
  320. $ref: '#/components/requestBodies/User'
  321. responses:
  322. 201:
  323. $ref: '#/components/responses/successAddUser'
  324. 400:
  325. $ref: '#/components/responses/400'
  326. 401:
  327. $ref: '#/components/responses/UnauthorizedError'
  328. 409:
  329. $ref: '#/components/responses/409'
  330. 413:
  331. $ref: '#/components/responses/413'
  332. security:
  333. - testAuth: []
  334. /users/{userId}:
  335. get:
  336. tags:
  337. - users
  338. summary: find user by userId
  339. description: return user by userId
  340. operationId: getUserById
  341. parameters:
  342. - $ref: '#/components/parameters/UserPath'
  343. responses:
  344. 200:
  345. $ref: '#/components/responses/getSingleUser'
  346. 401:
  347. $ref: '#/components/responses/UnauthorizedError'
  348. 404:
  349. $ref: '#/components/responses/404'
  350. security:
  351. - testAuth: []
  352. put:
  353. tags:
  354. - users
  355. summary: update existing user except password
  356. description: update user
  357. operationId: updateUserById
  358. parameters:
  359. - $ref: '#/components/parameters/UserPath'
  360. requestBody:
  361. description: User object
  362. required: true
  363. content:
  364. application/json:
  365. schema:
  366. type: object
  367. properties:
  368. username:
  369. type: string
  370. example: abi
  371. name:
  372. type: string
  373. example: abidzar
  374. responses:
  375. 200:
  376. $ref: '#/components/responses/getSingleUser'
  377. 400:
  378. $ref: '#/components/responses/400'
  379. 401:
  380. $ref: '#/components/responses/UnauthorizedError'
  381. 404:
  382. $ref: '#/components/responses/404'
  383. 409:
  384. $ref: '#/components/responses/409'
  385. 413:
  386. $ref: '#/components/responses/413'
  387. security:
  388. - testAuth: []
  389. delete:
  390. tags:
  391. - users
  392. summary: deletes a user by ID
  393. description: delete a user by ID
  394. operationId: deleteUserById
  395. parameters:
  396. - $ref: '#/components/parameters/UserPath'
  397. responses:
  398. 200:
  399. description: successful operation
  400. 205:
  401. description: Unable to delete. Data is used.
  402. 401:
  403. $ref: '#/components/responses/UnauthorizedError'
  404. 404:
  405. $ref: '#/components/responses/404'
  406. security:
  407. - testAuth: []
  408. /users/{userId}/password:
  409. put:
  410. tags:
  411. - users
  412. summary: change password
  413. description: update user password
  414. operationId: updatePassword
  415. parameters:
  416. - $ref: '#/components/parameters/UserPath'
  417. requestBody:
  418. description: User object
  419. required: true
  420. content:
  421. application/json:
  422. schema:
  423. type: object
  424. properties:
  425. oldPassword:
  426. type: string
  427. example: abi123
  428. newPassword:
  429. type: string
  430. example: abi456
  431. responses:
  432. 200:
  433. $ref: '#/components/responses/getSingleUser'
  434. 400:
  435. $ref: '#/components/responses/400'
  436. 401:
  437. $ref: '#/components/responses/UnauthorizedError'
  438. 403:
  439. description: wrong old password
  440. 404:
  441. $ref: '#/components/responses/404'
  442. security:
  443. - testAuth: []
  444. components:
  445. schemas:
  446. Project:
  447. required:
  448. - id
  449. - name
  450. - owner
  451. type: object
  452. properties:
  453. id:
  454. type: integer
  455. uniqueItems: true
  456. example: 2
  457. name:
  458. type: string
  459. uniqueItems: true
  460. maximum: 100
  461. example: PI
  462. description:
  463. type: string
  464. maximum: 255
  465. example: PropInspector
  466. owner:
  467. $ref: '#/components/schemas/User'
  468. Platform:
  469. type: object
  470. required:
  471. - id
  472. - name
  473. properties:
  474. id:
  475. type: integer
  476. uniqueItems: true
  477. example: 3
  478. name:
  479. type: string
  480. uniqueItems: true
  481. maximum: 100
  482. example: mobile
  483. project_id:
  484. $ref: '#/components/schemas/Project'
  485. User:
  486. type: object
  487. required:
  488. - id
  489. - username
  490. - password
  491. - name
  492. properties:
  493. id:
  494. type: integer
  495. uniqueItems: true
  496. example: 4
  497. username:
  498. type: string
  499. uniqueItems: true
  500. maximum: 100
  501. example: abi
  502. password:
  503. type: string
  504. maximum: 100
  505. example: abi123
  506. name:
  507. type: string
  508. maximum: 255
  509. example: abidzar
  510. project_member:
  511. type: object
  512. properties:
  513. id:
  514. type: integer
  515. uniqueItems: true
  516. project:
  517. $ref: '#/components/schemas/Project'
  518. user:
  519. $ref: '#/components/schemas/User'
  520. role:
  521. type: number
  522. enum: [0,1,2]
  523. description: role = 0.QC, 1. Programmer, 2.Admin
  524. required:
  525. - id
  526. - project
  527. - user
  528. - role
  529. parameters:
  530. projectPath:
  531. name: projectId
  532. in: path
  533. description: Project ID
  534. required: true
  535. schema:
  536. type: integer
  537. platformPath:
  538. name: platformId
  539. in: path
  540. description: Platform ID
  541. required: true
  542. schema:
  543. type: integer
  544. UserPath:
  545. name: userId
  546. in: path
  547. description: User ID
  548. required: true
  549. schema:
  550. type: integer
  551. projectQuery:
  552. name: project
  553. in: query
  554. description: Project ID
  555. schema:
  556. type: integer
  557. memberPath:
  558. name: memberId
  559. in: path
  560. description: Project Member ID
  561. required: true
  562. schema:
  563. type: integer
  564. responses:
  565. getArrayProject:
  566. description: successful operation
  567. content:
  568. application/json:
  569. schema:
  570. type: array
  571. items:
  572. properties:
  573. id:
  574. type: integer
  575. example: 1
  576. name:
  577. type: string
  578. example: TM
  579. description:
  580. type: string
  581. example: TelMesengger
  582. owner:
  583. properties:
  584. id:
  585. type: integer
  586. example: 1
  587. username:
  588. type: string
  589. example: abi
  590. name:
  591. type: string
  592. example: abidzar
  593. getSingleProject:
  594. description: successful operation
  595. content:
  596. application/json:
  597. schema:
  598. properties:
  599. id:
  600. type: integer
  601. example: 1
  602. name:
  603. type: string
  604. example: TM
  605. description:
  606. type: string
  607. example: TelMesengger
  608. owner:
  609. properties:
  610. id:
  611. type: integer
  612. example: 1
  613. username:
  614. type: string
  615. example: abi
  616. name:
  617. type: string
  618. example: abidzar
  619. successAddProject:
  620. description: record successfully added
  621. content:
  622. application/json:
  623. schema:
  624. properties:
  625. id:
  626. type: integer
  627. example: 1
  628. name:
  629. type: string
  630. example: TM
  631. description:
  632. type: string
  633. example: TelMesengger
  634. owner:
  635. properties:
  636. id:
  637. type: integer
  638. example: 1
  639. username:
  640. type: string
  641. example: abi
  642. name:
  643. type: string
  644. example: abidzar
  645. successAddMember:
  646. description: record successfully added
  647. content:
  648. application/json:
  649. schema:
  650. properties:
  651. id:
  652. type: integer
  653. example: 1
  654. project:
  655. example: TelMessenger
  656. user:
  657. example: abidzar
  658. role:
  659. type: string
  660. example: QC
  661. getArrayPlatform:
  662. description: successful operation
  663. content:
  664. application/json:
  665. schema:
  666. type: array
  667. items:
  668. properties:
  669. id:
  670. type: integer
  671. example: 1
  672. name:
  673. type: string
  674. example: mobile
  675. project_id:
  676. properties:
  677. id:
  678. type: integer
  679. example: 1
  680. name:
  681. type: string
  682. example: TM
  683. description:
  684. type: string
  685. example: TelMessenger
  686. owner:
  687. properties:
  688. id:
  689. type: integer
  690. example: 1
  691. username:
  692. type: string
  693. example: abi
  694. name:
  695. type: string
  696. example: abidzar
  697. successAddPlatform:
  698. description: record successfully added
  699. content:
  700. application/json:
  701. schema:
  702. properties:
  703. id:
  704. type: integer
  705. example: 1
  706. name:
  707. type: string
  708. example: mobile
  709. project_id:
  710. properties:
  711. id:
  712. type: integer
  713. example: 1
  714. name:
  715. type: string
  716. example: TM
  717. description:
  718. type: string
  719. example: TelMessenger
  720. owner:
  721. properties:
  722. id:
  723. type: integer
  724. example: 1
  725. username:
  726. type: string
  727. example: abi
  728. name:
  729. type: string
  730. example: abidzar
  731. getSinglePlatform:
  732. description: successful operation
  733. content:
  734. application/json:
  735. schema:
  736. properties:
  737. id:
  738. type: integer
  739. example: 1
  740. name:
  741. type: string
  742. example: mobile
  743. project_id:
  744. properties:
  745. id:
  746. type: integer
  747. example: 1
  748. name:
  749. type: string
  750. example: TM
  751. description:
  752. type: string
  753. example: TelMessenger
  754. owner:
  755. properties:
  756. id:
  757. type: integer
  758. example: 1
  759. username:
  760. type: string
  761. example: abi
  762. name:
  763. type: string
  764. example: abidzar
  765. getArrayUser:
  766. description: successful operation
  767. content:
  768. application/json:
  769. schema:
  770. type: array
  771. items:
  772. properties:
  773. id:
  774. type: integer
  775. example: 1
  776. username:
  777. type: string
  778. example: abi
  779. name:
  780. type: string
  781. example: abidzar
  782. successAddUser:
  783. description: record successfully added
  784. content:
  785. application/json:
  786. schema:
  787. properties:
  788. id:
  789. type: integer
  790. example: 1
  791. username:
  792. type: string
  793. example: abi
  794. name:
  795. type: string
  796. example: abidzar
  797. getSingleUser:
  798. description: successful operation
  799. content:
  800. application/json:
  801. schema:
  802. properties:
  803. id:
  804. type: integer
  805. example: 1
  806. username:
  807. type: string
  808. example: abi
  809. name:
  810. type: string
  811. example: abidzar
  812. getSingleMember:
  813. description: successful operation
  814. content:
  815. application/json:
  816. schema:
  817. properties:
  818. id:
  819. example: 1
  820. project:
  821. example: TelMessenger
  822. user:
  823. example: abidzar
  824. role:
  825. example: QC
  826. getArrayMember:
  827. description: successful operation
  828. content:
  829. application/json:
  830. schema:
  831. type: array
  832. items:
  833. properties:
  834. id:
  835. example: 1
  836. project:
  837. example: TelMessenger
  838. user:
  839. example: abidzar
  840. role:
  841. example: QC
  842. 400:
  843. description: invalid data
  844. 403:
  845. description: do not have rights
  846. UnauthorizedError:
  847. description: Authentication information is missing or invalid
  848. 404:
  849. description: not found
  850. 409:
  851. description: duplicate data
  852. 413:
  853. description: content too large
  854. requestBodies:
  855. Project:
  856. description: Project object
  857. required: true
  858. content:
  859. application/json:
  860. schema:
  861. type: object
  862. properties:
  863. name:
  864. type: string
  865. example: TM
  866. description:
  867. type: string
  868. example: TelMesengger
  869. ProjectMember:
  870. description: project member object
  871. required: true
  872. content:
  873. application/json:
  874. schema:
  875. type: object
  876. properties:
  877. user_id:
  878. type: integer
  879. example: 1
  880. role:
  881. type: string
  882. example: qc
  883. Platform:
  884. description: Platform object
  885. required: true
  886. content:
  887. application/json:
  888. schema:
  889. type: object
  890. properties:
  891. name:
  892. type: string
  893. example: web
  894. project_name:
  895. type: string
  896. example: TM
  897. User:
  898. description: User object
  899. required: true
  900. content:
  901. application/json:
  902. schema:
  903. type: object
  904. properties:
  905. username:
  906. type: string
  907. example: abi
  908. password:
  909. type: string
  910. example: abi123
  911. name:
  912. type: string
  913. example: abidzar
  914. securitySchemes:
  915. testAuth:
  916. type: http
  917. scheme: basic
  918. description: use `user`/`password` to login