swagger3 project.yml 26 KB

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