workout-id.yaml 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. get:
  2. summary: Get a workout
  3. operationId: getWorkout
  4. tags:
  5. - Workouts
  6. security:
  7. - cookieAuth: []
  8. parameters:
  9. - name: id
  10. in: path
  11. required: true
  12. description: UUID of the workout to retrieve.
  13. schema:
  14. type: string
  15. format: uuid
  16. example: 0191a23b-dead-7000-beef-000000000002
  17. responses:
  18. '200':
  19. description: Workout with all exercises.
  20. content:
  21. application/json:
  22. schema:
  23. type: object
  24. required:
  25. - id
  26. - name
  27. - exercises
  28. properties:
  29. id:
  30. type: string
  31. format: uuid
  32. example: 0191a23b-dead-7000-beef-000000000002
  33. name:
  34. type: string
  35. example: Push Day
  36. exercises:
  37. type: array
  38. items:
  39. type: object
  40. required:
  41. - id
  42. - name
  43. - exercise_type
  44. - position
  45. properties:
  46. id:
  47. type: string
  48. format: uuid
  49. example: 0191a23b-dead-7000-beef-000000000003
  50. name:
  51. type: string
  52. example: Bench Press
  53. notes:
  54. type: string
  55. nullable: true
  56. example: Keep elbows tucked
  57. exercise_type:
  58. $ref: '../components/schemas/ExerciseType.yaml'
  59. position:
  60. type: integer
  61. description: 1-based position of the exercise within its workout.
  62. example: 1
  63. example:
  64. id: 0191a23b-dead-7000-beef-000000000002
  65. name: Push Day
  66. exercises:
  67. - id: 0191a23b-dead-7000-beef-000000000003
  68. name: Bench Press
  69. notes: null
  70. exercise_type: WeightedReps
  71. position: 1
  72. - id: 0191a23b-dead-7000-beef-000000000004
  73. name: Push-ups
  74. notes: null
  75. exercise_type: BodyweightReps
  76. position: 2
  77. '401':
  78. description: Missing or invalid auth token.
  79. content:
  80. application/json:
  81. schema:
  82. $ref: '../components/schemas/ErrorResponse.yaml'
  83. examples:
  84. missing:
  85. summary: No cookie present
  86. value:
  87. error: Missing auth token
  88. invalid:
  89. summary: Token invalid or expired
  90. value:
  91. error: Invalid auth token
  92. '404':
  93. description: Workout not found.
  94. content:
  95. application/json:
  96. schema:
  97. $ref: '../components/schemas/ErrorResponse.yaml'
  98. example:
  99. error: Workout not found
  100. '500':
  101. description: Internal server error.
  102. content:
  103. application/json:
  104. schema:
  105. $ref: '../components/schemas/ErrorResponse.yaml'
  106. put:
  107. summary: Update a workout
  108. operationId: updateWorkout
  109. tags:
  110. - Workouts
  111. security:
  112. - cookieAuth: []
  113. parameters:
  114. - name: id
  115. in: path
  116. required: true
  117. description: UUID of the workout to update.
  118. schema:
  119. type: string
  120. format: uuid
  121. example: 0191a23b-dead-7000-beef-000000000002
  122. requestBody:
  123. required: true
  124. content:
  125. application/json:
  126. schema:
  127. type: object
  128. properties:
  129. name:
  130. type: string
  131. description: New name for the workout.
  132. example: Push Day (Heavy)
  133. exercises:
  134. type: array
  135. description: Complete replacement list of exercises. Omit to leave exercises unchanged.
  136. items:
  137. type: object
  138. required:
  139. - name
  140. - exercise_type
  141. - position
  142. properties:
  143. name:
  144. type: string
  145. example: Incline Bench Press
  146. exercise_type:
  147. $ref: '../components/schemas/ExerciseType.yaml'
  148. position:
  149. type: integer
  150. description: 1-based position of the exercise within the workout. Must be unique.
  151. example: 1
  152. example:
  153. name: Push Day (Heavy)
  154. exercises:
  155. - name: Incline Bench Press
  156. exercise_type: WeightedReps
  157. position: 1
  158. - name: Dips
  159. exercise_type: BodyweightReps
  160. position: 2
  161. responses:
  162. '200':
  163. description: Workout updated successfully. Returns the full updated workout.
  164. content:
  165. application/json:
  166. schema:
  167. type: object
  168. required:
  169. - id
  170. - name
  171. - exercises
  172. properties:
  173. id:
  174. type: string
  175. format: uuid
  176. example: 0191a23b-dead-7000-beef-000000000002
  177. name:
  178. type: string
  179. example: Push Day (Heavy)
  180. exercises:
  181. type: array
  182. items:
  183. type: object
  184. required:
  185. - id
  186. - name
  187. - exercise_type
  188. - position
  189. properties:
  190. id:
  191. type: string
  192. format: uuid
  193. example: 0191a23b-dead-7000-beef-000000000003
  194. name:
  195. type: string
  196. example: Incline Bench Press
  197. notes:
  198. type: string
  199. nullable: true
  200. example: null
  201. exercise_type:
  202. $ref: '../components/schemas/ExerciseType.yaml'
  203. position:
  204. type: integer
  205. example: 1
  206. example:
  207. id: 0191a23b-dead-7000-beef-000000000002
  208. name: Push Day (Heavy)
  209. exercises:
  210. - id: 0191a23b-dead-7000-beef-000000000005
  211. name: Incline Bench Press
  212. notes: null
  213. exercise_type: WeightedReps
  214. position: 1
  215. - id: 0191a23b-dead-7000-beef-000000000006
  216. name: Dips
  217. notes: null
  218. exercise_type: BodyweightReps
  219. position: 2
  220. '401':
  221. description: Missing or invalid auth token.
  222. content:
  223. application/json:
  224. schema:
  225. $ref: '../components/schemas/ErrorResponse.yaml'
  226. examples:
  227. missing:
  228. summary: No cookie present
  229. value:
  230. error: Missing auth token
  231. invalid:
  232. summary: Token invalid or expired
  233. value:
  234. error: Invalid auth token
  235. '403':
  236. description: Authenticated user does not own this workout.
  237. content:
  238. application/json:
  239. schema:
  240. $ref: '../components/schemas/ErrorResponse.yaml'
  241. example:
  242. error: You do not have permission to update this workout
  243. '404':
  244. description: Workout or exercise not found.
  245. content:
  246. application/json:
  247. schema:
  248. $ref: '../components/schemas/ErrorResponse.yaml'
  249. example:
  250. error: Workout not found
  251. '422':
  252. description: Two or more exercises share the same position.
  253. content:
  254. application/json:
  255. schema:
  256. $ref: '../components/schemas/ErrorResponse.yaml'
  257. example:
  258. error: Two or more exercises share the same position. Each exercise must have a unique position within the workout.
  259. '500':
  260. description: Internal server error.
  261. content:
  262. application/json:
  263. schema:
  264. $ref: '../components/schemas/ErrorResponse.yaml'
  265. delete:
  266. summary: Delete a workout
  267. operationId: deleteWorkout
  268. tags:
  269. - Workouts
  270. security:
  271. - cookieAuth: []
  272. parameters:
  273. - name: id
  274. in: path
  275. required: true
  276. description: UUID of the workout to delete.
  277. schema:
  278. type: string
  279. format: uuid
  280. example: 0191a23b-dead-7000-beef-000000000002
  281. responses:
  282. '200':
  283. description: Workout and all its exercises deleted successfully.
  284. content:
  285. application/json:
  286. schema:
  287. $ref: '../components/schemas/SuccessResponse.yaml'
  288. example:
  289. success: true
  290. '401':
  291. description: Missing or invalid auth token.
  292. content:
  293. application/json:
  294. schema:
  295. $ref: '../components/schemas/ErrorResponse.yaml'
  296. examples:
  297. missing:
  298. summary: No cookie present
  299. value:
  300. error: Missing auth token
  301. invalid:
  302. summary: Token invalid or expired
  303. value:
  304. error: Invalid auth token
  305. '403':
  306. description: Authenticated user does not own this workout.
  307. content:
  308. application/json:
  309. schema:
  310. $ref: '../components/schemas/ErrorResponse.yaml'
  311. example:
  312. error: You do not have permission to delete this workout
  313. '404':
  314. description: Workout not found.
  315. content:
  316. application/json:
  317. schema:
  318. $ref: '../components/schemas/ErrorResponse.yaml'
  319. example:
  320. error: Workout not found
  321. '500':
  322. description: Internal server error.
  323. content:
  324. application/json:
  325. schema:
  326. $ref: '../components/schemas/ErrorResponse.yaml'