swagger3 project.yml 13 KB

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