swagger3 project.yml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982
  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. 404:
  174. $ref: '#/components/responses/404'
  175. security:
  176. - testAuth: []
  177. delete:
  178. tags:
  179. - projects
  180. summary: delete project member
  181. description: delete project member
  182. operationId: deleteProjectMember
  183. parameters:
  184. - $ref: '#/components/parameters/memberPath'
  185. responses:
  186. 200:
  187. description: successful operation
  188. 401:
  189. $ref: '#/components/responses/UnauthorizedError'
  190. 403:
  191. $ref: '#/components/responses/403'
  192. 404:
  193. $ref: '#/components/responses/404'
  194. security:
  195. - testAuth: []
  196. /platforms:
  197. get:
  198. tags:
  199. - platforms
  200. summary: find all platform of a project
  201. description: return all platform of a project
  202. operationId: getPlatformByProjectId
  203. parameters:
  204. - $ref: '#/components/parameters/projectQuery'
  205. responses:
  206. 200:
  207. $ref: '#/components/responses/getArrayPlatform'
  208. 401:
  209. $ref: '#/components/responses/UnauthorizedError'
  210. security:
  211. - testAuth: []
  212. post:
  213. tags:
  214. - platforms
  215. summary: Add new platform for a project
  216. description: add new platform for a project
  217. operationId: addPlatformByProjectId
  218. requestBody:
  219. $ref: '#/components/requestBodies/Platform'
  220. responses:
  221. 201:
  222. $ref: '#/components/responses/successAddPlatform'
  223. 400:
  224. $ref: '#/components/responses/400'
  225. 401:
  226. $ref: '#/components/responses/UnauthorizedError'
  227. 403:
  228. $ref: '#/components/responses/403'
  229. 404:
  230. $ref: '#/components/responses/404'
  231. 409:
  232. $ref: '#/components/responses/409'
  233. 413:
  234. $ref: '#/components/responses/413'
  235. security:
  236. - testAuth: []
  237. /platforms/{platformId}:
  238. get:
  239. tags:
  240. - platforms
  241. summary: find platform by ID
  242. description: return platform by ID
  243. operationId: getPlatformById
  244. parameters:
  245. - $ref: '#/components/parameters/platformPath'
  246. responses:
  247. 200:
  248. $ref: '#/components/responses/getSinglePlatform'
  249. 401:
  250. $ref: '#/components/responses/UnauthorizedError'
  251. 404:
  252. $ref: '#/components/responses/404'
  253. security:
  254. - testAuth: []
  255. put:
  256. tags:
  257. - platforms
  258. summary: update existing platform by ID
  259. description: update platform
  260. operationId: updatePlatformById
  261. parameters:
  262. - $ref: '#/components/parameters/platformPath'
  263. requestBody:
  264. $ref: '#/components/requestBodies/Platform'
  265. responses:
  266. 200:
  267. $ref: '#/components/responses/getSinglePlatform'
  268. 400:
  269. $ref: '#/components/responses/400'
  270. 401:
  271. $ref: '#/components/responses/UnauthorizedError'
  272. 403:
  273. $ref: '#/components/responses/403'
  274. 404:
  275. $ref: '#/components/responses/404'
  276. 409:
  277. $ref: '#/components/responses/409'
  278. 413:
  279. $ref: '#/components/responses/413'
  280. security:
  281. - testAuth: []
  282. delete:
  283. tags:
  284. - platforms
  285. summary: deletes a platform by ID
  286. description: delete a platform by ID
  287. operationId: deletePlatformById
  288. parameters:
  289. - $ref: '#/components/parameters/platformPath'
  290. responses:
  291. 200:
  292. description: successful operation
  293. 401:
  294. $ref: '#/components/responses/UnauthorizedError'
  295. 403:
  296. $ref: '#/components/responses/403'
  297. 404:
  298. $ref: '#/components/responses/404'
  299. security:
  300. - testAuth: []
  301. /users:
  302. get:
  303. tags:
  304. - users
  305. summary: find all user
  306. description: return all user
  307. operationId: getUser
  308. responses:
  309. 200:
  310. $ref: '#/components/responses/getArrayUser'
  311. 401:
  312. $ref: '#/components/responses/UnauthorizedError'
  313. security:
  314. - testAuth: []
  315. post:
  316. tags:
  317. - users
  318. summary: add user
  319. description: add new user
  320. operationId: AddUser
  321. requestBody:
  322. $ref: '#/components/requestBodies/User'
  323. responses:
  324. 201:
  325. $ref: '#/components/responses/successAddUser'
  326. 400:
  327. $ref: '#/components/responses/400'
  328. 401:
  329. $ref: '#/components/responses/UnauthorizedError'
  330. 409:
  331. $ref: '#/components/responses/409'
  332. 413:
  333. $ref: '#/components/responses/413'
  334. security:
  335. - testAuth: []
  336. /users/{userId}:
  337. get:
  338. tags:
  339. - users
  340. summary: find user by userId
  341. description: return user by userId
  342. operationId: getUserById
  343. parameters:
  344. - $ref: '#/components/parameters/UserPath'
  345. responses:
  346. 200:
  347. $ref: '#/components/responses/getSingleUser'
  348. 401:
  349. $ref: '#/components/responses/UnauthorizedError'
  350. 404:
  351. $ref: '#/components/responses/404'
  352. security:
  353. - testAuth: []
  354. put:
  355. tags:
  356. - users
  357. summary: update existing user except password
  358. description: update user
  359. operationId: updateUserById
  360. parameters:
  361. - $ref: '#/components/parameters/UserPath'
  362. requestBody:
  363. description: User object
  364. required: true
  365. content:
  366. application/json:
  367. schema:
  368. type: object
  369. properties:
  370. username:
  371. type: string
  372. example: abi
  373. name:
  374. type: string
  375. example: abidzar
  376. responses:
  377. 200:
  378. $ref: '#/components/responses/getSingleUser'
  379. 400:
  380. $ref: '#/components/responses/400'
  381. 401:
  382. $ref: '#/components/responses/UnauthorizedError'
  383. 404:
  384. $ref: '#/components/responses/404'
  385. 409:
  386. $ref: '#/components/responses/409'
  387. 413:
  388. $ref: '#/components/responses/413'
  389. security:
  390. - testAuth: []
  391. delete:
  392. tags:
  393. - users
  394. summary: deletes a user by ID
  395. description: delete a user by ID
  396. operationId: deleteUserById
  397. parameters:
  398. - $ref: '#/components/parameters/UserPath'
  399. responses:
  400. 200:
  401. description: successful operation
  402. 205:
  403. description: Unable to delete. Data is used.
  404. 401:
  405. $ref: '#/components/responses/UnauthorizedError'
  406. 404:
  407. $ref: '#/components/responses/404'
  408. security:
  409. - testAuth: []
  410. /users/{userId}/password:
  411. put:
  412. tags:
  413. - users
  414. summary: change password
  415. description: update user password
  416. operationId: updatePassword
  417. parameters:
  418. - $ref: '#/components/parameters/UserPath'
  419. requestBody:
  420. description: User object
  421. required: true
  422. content:
  423. application/json:
  424. schema:
  425. type: object
  426. properties:
  427. oldPassword:
  428. type: string
  429. example: abi123
  430. newPassword:
  431. type: string
  432. example: abi456
  433. responses:
  434. 200:
  435. $ref: '#/components/responses/getSingleUser'
  436. 400:
  437. $ref: '#/components/responses/400'
  438. 401:
  439. $ref: '#/components/responses/UnauthorizedError'
  440. 403:
  441. description: wrong old password
  442. 404:
  443. $ref: '#/components/responses/404'
  444. security:
  445. - testAuth: []
  446. components:
  447. schemas:
  448. Project:
  449. required:
  450. - id
  451. - name
  452. - owner
  453. type: object
  454. properties:
  455. id:
  456. type: integer
  457. uniqueItems: true
  458. example: 2
  459. name:
  460. type: string
  461. uniqueItems: true
  462. maximum: 100
  463. example: PI
  464. description:
  465. type: string
  466. maximum: 255
  467. example: PropInspector
  468. owner:
  469. $ref: '#/components/schemas/User'
  470. Platform:
  471. type: object
  472. required:
  473. - id
  474. - name
  475. properties:
  476. id:
  477. type: integer
  478. uniqueItems: true
  479. example: 3
  480. name:
  481. type: string
  482. uniqueItems: true
  483. maximum: 100
  484. example: mobile
  485. project_id:
  486. $ref: '#/components/schemas/Project'
  487. User:
  488. type: object
  489. required:
  490. - id
  491. - username
  492. - password
  493. - name
  494. properties:
  495. id:
  496. type: integer
  497. uniqueItems: true
  498. example: 4
  499. username:
  500. type: string
  501. uniqueItems: true
  502. maximum: 100
  503. example: abi
  504. password:
  505. type: string
  506. maximum: 100
  507. example: abi123
  508. name:
  509. type: string
  510. maximum: 255
  511. example: abidzar
  512. project_member:
  513. type: object
  514. properties:
  515. id:
  516. type: integer
  517. uniqueItems: true
  518. project_id:
  519. $ref: '#/components/schemas/Project'
  520. user_id:
  521. $ref: '#/components/schemas/User'
  522. role:
  523. type: number
  524. format: int32
  525. description: role = 0.QC, 1. Programmer, 2.Admin
  526. required:
  527. - id
  528. - project_id
  529. - user_id
  530. - role
  531. parameters:
  532. projectPath:
  533. name: projectId
  534. in: path
  535. description: Project ID
  536. required: true
  537. schema:
  538. type: integer
  539. platformPath:
  540. name: platformId
  541. in: path
  542. description: Platform ID
  543. required: true
  544. schema:
  545. type: integer
  546. UserPath:
  547. name: userId
  548. in: path
  549. description: User ID
  550. required: true
  551. schema:
  552. type: integer
  553. projectQuery:
  554. name: project
  555. in: query
  556. description: Project ID
  557. schema:
  558. type: integer
  559. memberPath:
  560. name: memberId
  561. in: path
  562. description: Project Member ID
  563. required: true
  564. schema:
  565. type: integer
  566. responses:
  567. getArrayProject:
  568. description: successful operation
  569. content:
  570. application/json:
  571. schema:
  572. type: array
  573. items:
  574. properties:
  575. id:
  576. type: integer
  577. example: 1
  578. name:
  579. type: string
  580. example: TM
  581. description:
  582. type: string
  583. example: TelMesengger
  584. owner:
  585. properties:
  586. id:
  587. type: integer
  588. example: 1
  589. username:
  590. type: string
  591. example: abi
  592. name:
  593. type: string
  594. example: abidzar
  595. getSingleProject:
  596. description: successful operation
  597. content:
  598. application/json:
  599. schema:
  600. properties:
  601. id:
  602. type: integer
  603. example: 1
  604. name:
  605. type: string
  606. example: TM
  607. description:
  608. type: string
  609. example: TelMesengger
  610. owner:
  611. properties:
  612. id:
  613. type: integer
  614. example: 1
  615. username:
  616. type: string
  617. example: abi
  618. name:
  619. type: string
  620. example: abidzar
  621. successAddProject:
  622. description: record successfully added
  623. content:
  624. application/json:
  625. schema:
  626. properties:
  627. id:
  628. type: integer
  629. example: 1
  630. name:
  631. type: string
  632. example: TM
  633. description:
  634. type: string
  635. example: TelMesengger
  636. owner:
  637. properties:
  638. id:
  639. type: integer
  640. example: 1
  641. username:
  642. type: string
  643. example: abi
  644. name:
  645. type: string
  646. example: abidzar
  647. successAddMember:
  648. description: record successfully added
  649. content:
  650. application/json:
  651. schema:
  652. properties:
  653. id:
  654. type: integer
  655. example: 1
  656. project_id:
  657. properties:
  658. id:
  659. example: 1
  660. name:
  661. example: TM
  662. description:
  663. example: TelMessenger
  664. owner:
  665. properties:
  666. id:
  667. example: 1
  668. username:
  669. example: abi
  670. name:
  671. example: abidzar
  672. user_id:
  673. properties:
  674. id:
  675. example: 1
  676. username:
  677. example: abi
  678. name:
  679. example: abidzar
  680. role:
  681. type: integer
  682. example: 0
  683. description: QC
  684. getArrayPlatform:
  685. description: successful operation
  686. content:
  687. application/json:
  688. schema:
  689. type: array
  690. items:
  691. properties:
  692. id:
  693. type: integer
  694. example: 1
  695. name:
  696. type: string
  697. example: mobile
  698. project_id:
  699. properties:
  700. id:
  701. type: integer
  702. example: 1
  703. name:
  704. type: string
  705. example: TM
  706. description:
  707. type: string
  708. example: TelMessenger
  709. owner:
  710. properties:
  711. id:
  712. type: integer
  713. example: 1
  714. username:
  715. type: string
  716. example: abi
  717. name:
  718. type: string
  719. example: abidzar
  720. successAddPlatform:
  721. description: record successfully added
  722. content:
  723. application/json:
  724. schema:
  725. properties:
  726. id:
  727. type: integer
  728. example: 1
  729. name:
  730. type: string
  731. example: mobile
  732. project_id:
  733. properties:
  734. id:
  735. type: integer
  736. example: 1
  737. name:
  738. type: string
  739. example: TM
  740. description:
  741. type: string
  742. example: TelMessenger
  743. owner:
  744. properties:
  745. id:
  746. type: integer
  747. example: 1
  748. username:
  749. type: string
  750. example: abi
  751. name:
  752. type: string
  753. example: abidzar
  754. getSinglePlatform:
  755. description: successful operation
  756. content:
  757. application/json:
  758. schema:
  759. properties:
  760. id:
  761. type: integer
  762. example: 1
  763. name:
  764. type: string
  765. example: mobile
  766. project_id:
  767. properties:
  768. id:
  769. type: integer
  770. example: 1
  771. name:
  772. type: string
  773. example: TM
  774. description:
  775. type: string
  776. example: TelMessenger
  777. owner:
  778. properties:
  779. id:
  780. type: integer
  781. example: 1
  782. username:
  783. type: string
  784. example: abi
  785. name:
  786. type: string
  787. example: abidzar
  788. getArrayUser:
  789. description: successful operation
  790. content:
  791. application/json:
  792. schema:
  793. type: array
  794. items:
  795. properties:
  796. id:
  797. type: integer
  798. example: 1
  799. username:
  800. type: string
  801. example: abi
  802. name:
  803. type: string
  804. example: abidzar
  805. successAddUser:
  806. description: record successfully added
  807. content:
  808. application/json:
  809. schema:
  810. properties:
  811. id:
  812. type: integer
  813. example: 1
  814. username:
  815. type: string
  816. example: abi
  817. name:
  818. type: string
  819. example: abidzar
  820. getSingleUser:
  821. description: successful operation
  822. content:
  823. application/json:
  824. schema:
  825. properties:
  826. id:
  827. type: integer
  828. example: 1
  829. username:
  830. type: string
  831. example: abi
  832. name:
  833. type: string
  834. example: abidzar
  835. getSingleMember:
  836. description: successful operation
  837. content:
  838. application/json:
  839. schema:
  840. properties:
  841. id:
  842. example: 1
  843. project_id:
  844. properties:
  845. id:
  846. example: 1
  847. name:
  848. example: TM
  849. description:
  850. example: TelMessenger
  851. owner:
  852. properties:
  853. id:
  854. example: 1
  855. username:
  856. example: abi
  857. name:
  858. example: abidzar
  859. user_id:
  860. properties:
  861. id:
  862. example: 1
  863. username:
  864. example: abi
  865. name:
  866. example: abidzar
  867. role:
  868. example: 0
  869. getArrayMember:
  870. description: successful operation
  871. content:
  872. application/json:
  873. schema:
  874. type: array
  875. items:
  876. properties:
  877. id:
  878. example: 1
  879. project_id:
  880. properties:
  881. id:
  882. example: 1
  883. name:
  884. example: TM
  885. description:
  886. example: TelMessenger
  887. owner:
  888. properties:
  889. id:
  890. example: 1
  891. username:
  892. example: abi
  893. name:
  894. example: abidzar
  895. user_id:
  896. properties:
  897. id:
  898. example: 1
  899. username:
  900. example: abi
  901. name:
  902. example: abidzar
  903. role:
  904. example: 0
  905. 400:
  906. description: invalid data
  907. 403:
  908. description: do not have rights
  909. UnauthorizedError:
  910. description: Authentication information is missing or invalid
  911. 404:
  912. description: not found
  913. 409:
  914. description: duplicate data
  915. 413:
  916. description: content too large
  917. requestBodies:
  918. Project:
  919. description: Project object
  920. required: true
  921. content:
  922. application/json:
  923. schema:
  924. type: object
  925. properties:
  926. name:
  927. type: string
  928. example: TM
  929. description:
  930. type: string
  931. example: TelMesengger
  932. ProjectMember:
  933. description: project member object
  934. required: true
  935. content:
  936. application/json:
  937. schema:
  938. type: object
  939. properties:
  940. user_id:
  941. type: integer
  942. example: 1
  943. role:
  944. type: string
  945. example: qc
  946. Platform:
  947. description: Platform object
  948. required: true
  949. content:
  950. application/json:
  951. schema:
  952. type: object
  953. properties:
  954. name:
  955. type: string
  956. example: web
  957. project_name:
  958. type: string
  959. example: TM
  960. User:
  961. description: User object
  962. required: true
  963. content:
  964. application/json:
  965. schema:
  966. type: object
  967. properties:
  968. username:
  969. type: string
  970. example: abi
  971. password:
  972. type: string
  973. example: abi123
  974. name:
  975. type: string
  976. example: abidzar
  977. securitySchemes:
  978. testAuth:
  979. type: http
  980. scheme: basic
  981. description: use `user`/`password` to login