swagger3 project.yml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. openapi: 3.0.1
  2. info:
  3. title: Project API
  4. description: Latihan Project API
  5. version: 2.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. paths:
  14. /projects:
  15. get:
  16. tags:
  17. - projects
  18. summary: find all project
  19. description: return all project
  20. operationId: getProject
  21. responses:
  22. 200:
  23. $ref: '#/components/responses/200AP'
  24. 204:
  25. $ref: '#/components/responses/204'
  26. post:
  27. tags:
  28. - projects
  29. summary: Add new Project
  30. description: Add new Project
  31. operationId: addProject
  32. requestBody:
  33. $ref: '#/components/requestBodies/Project'
  34. responses:
  35. 201:
  36. $ref: '#/components/responses/201'
  37. 400:
  38. $ref: '#/components/responses/400'
  39. 409:
  40. $ref: '#/components/responses/409'
  41. 413:
  42. $ref: '#/components/responses/413'
  43. /projects/{projectId}:
  44. get:
  45. tags:
  46. - projects
  47. summary: find project by ID
  48. description: return project
  49. operationId: getProjectById
  50. parameters:
  51. - $ref: '#/components/parameters/projectPath'
  52. responses:
  53. 200:
  54. $ref: '#/components/responses/200SP'
  55. 404:
  56. $ref: '#/components/responses/404'
  57. put:
  58. tags:
  59. - projects
  60. summary: update existing project by ID
  61. description: update project
  62. operationId: updateProjectById
  63. parameters:
  64. - $ref: '#/components/parameters/projectPath'
  65. requestBody:
  66. $ref: '#/components/requestBodies/Project'
  67. responses:
  68. 200:
  69. $ref: '#/components/responses/200AP'
  70. 400:
  71. $ref: '#/components/responses/400'
  72. 404:
  73. $ref: '#/components/responses/404'
  74. 409:
  75. $ref: '#/components/responses/409'
  76. 413:
  77. $ref: '#/components/responses/413'
  78. delete:
  79. tags:
  80. - projects
  81. summary: Deletes a project
  82. description: delete a project
  83. operationId: deleteProject
  84. parameters:
  85. - $ref: '#/components/parameters/projectPath'
  86. responses:
  87. 200:
  88. description: successful operation
  89. 205:
  90. description: Unable to delete. Data is used.
  91. 404:
  92. $ref: '#/components/responses/404'
  93. /platforms:
  94. get:
  95. tags:
  96. - platforms
  97. summary: find all platform of a project
  98. description: return all platform of a project
  99. operationId: getPlatformByProjectId
  100. parameters:
  101. - $ref: '#/components/parameters/projectQuery'
  102. responses:
  103. 200:
  104. description: successful operation
  105. content:
  106. application/json:
  107. schema:
  108. type: array
  109. items:
  110. $ref: '#/components/schemas/Platform'
  111. 204:
  112. $ref: '#/components/responses/204'
  113. post:
  114. tags:
  115. - platforms
  116. summary: Add new platform for a project
  117. description: add new platform for a project
  118. operationId: addPlatformByProjectId
  119. parameters:
  120. - name: project
  121. in: query
  122. description: Project ID
  123. required: true
  124. schema:
  125. type: integer
  126. requestBody:
  127. description: Platform object
  128. required: true
  129. content:
  130. application/json:
  131. schema:
  132. type: object
  133. properties:
  134. name:
  135. type: string
  136. example: web
  137. responses:
  138. 201:
  139. description: record successfully added
  140. content:
  141. application/json:
  142. schema:
  143. $ref: '#/components/schemas/Platform'
  144. 400:
  145. $ref: '#/components/responses/400'
  146. 404:
  147. $ref: '#/components/responses/404'
  148. 409:
  149. $ref: '#/components/responses/409'
  150. 413:
  151. $ref: '#/components/responses/413'
  152. /platforms/{platformId}:
  153. get:
  154. tags:
  155. - platforms
  156. summary: find platform by ID
  157. description: return platform by ID
  158. operationId: getPlatformById
  159. parameters:
  160. - $ref: '#/components/parameters/platformPath'
  161. responses:
  162. 200:
  163. description: successful operation
  164. content:
  165. application/json:
  166. schema:
  167. $ref: '#/components/schemas/Platform'
  168. 404:
  169. $ref: '#/components/responses/404'
  170. put:
  171. tags:
  172. - platforms
  173. summary: update existing platform by ID
  174. description: update platform
  175. operationId: updatePlatformById
  176. parameters:
  177. - $ref: '#/components/parameters/platformPath'
  178. requestBody:
  179. description: Platform object
  180. required: true
  181. content:
  182. application/json:
  183. schema:
  184. type: object
  185. properties:
  186. name:
  187. type: string
  188. example: web
  189. project_id:
  190. type: integer
  191. example: 1
  192. responses:
  193. 200:
  194. description: successful operation
  195. content:
  196. application/json:
  197. schema:
  198. $ref: '#/components/schemas/Platform'
  199. 400:
  200. $ref: '#/components/responses/400'
  201. 404:
  202. $ref: '#/components/responses/404'
  203. 409:
  204. $ref: '#/components/responses/409'
  205. 413:
  206. $ref: '#/components/responses/413'
  207. delete:
  208. tags:
  209. - platforms
  210. summary: deletes a platform by ID
  211. description: delete a platform by ID
  212. operationId: deletePlatformById
  213. parameters:
  214. - $ref: '#/components/parameters/platformPath'
  215. responses:
  216. 200:
  217. description: successful operation
  218. 404:
  219. $ref: '#/components/responses/404'
  220. components:
  221. schemas:
  222. Project:
  223. required:
  224. - id
  225. - name
  226. type: object
  227. properties:
  228. id:
  229. type: integer
  230. uniqueItems: true
  231. example: 2
  232. name:
  233. type: string
  234. uniqueItems: true
  235. maximum: 100
  236. example: PI
  237. description:
  238. type: string
  239. maximum: 255
  240. example: PropInspector
  241. Platform:
  242. type: object
  243. required:
  244. - id
  245. - name
  246. properties:
  247. id:
  248. type: integer
  249. uniqueItems: true
  250. example: 3
  251. name:
  252. type: string
  253. uniqueItems: true
  254. maximum: 100
  255. example: mobile
  256. project_id:
  257. $ref: '#/components/schemas/Project'
  258. parameters:
  259. projectPath:
  260. name: projectId
  261. in: path
  262. description: Project ID
  263. required: true
  264. schema:
  265. type: integer
  266. platformPath:
  267. name: platformId
  268. in: path
  269. description: Platform ID
  270. required: true
  271. schema:
  272. type: integer
  273. projectQuery:
  274. name: project
  275. in: query
  276. description: Project ID
  277. schema:
  278. type: integer
  279. responses:
  280. 200SP:
  281. description: successful operation
  282. content:
  283. application/json:
  284. schema:
  285. $ref: '#/components/schemas/Project'
  286. 200AP:
  287. description: successful operation
  288. content:
  289. application/json:
  290. schema:
  291. type: array
  292. items:
  293. $ref: '#/components/schemas/Project'
  294. 201:
  295. description: Record Successfully added
  296. content:
  297. application/json:
  298. schema:
  299. $ref: '#/components/schemas/Project'
  300. 204:
  301. description: empty data
  302. 400:
  303. description: invalid data
  304. 404:
  305. description: ID not found
  306. 409:
  307. description: duplicate data
  308. 413:
  309. description: content too large
  310. requestBodies:
  311. Project:
  312. description: Project object
  313. required: true
  314. content:
  315. application/json:
  316. schema:
  317. type: object
  318. properties:
  319. name:
  320. type: string
  321. example: TM
  322. description:
  323. type: string
  324. example: TelMesengger
  325. Platform:
  326. description: Platform object
  327. required: true
  328. content:
  329. application/json:
  330. schema:
  331. type: object
  332. properties:
  333. name:
  334. type: string
  335. example: mobile
  336. project_id:
  337. $ref: '#/components/schemas/Project'