workout-session.yaml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. get:
  2. summary: List sessions for a workout (paginated, filtered by date range)
  3. operationId: listWorkoutSessions
  4. tags:
  5. - Sessions
  6. security:
  7. - cookieAuth: []
  8. parameters:
  9. - name: workout_id
  10. in: path
  11. required: true
  12. description: UUID of the workout.
  13. schema:
  14. type: string
  15. format: uuid
  16. example: 0191a23b-dead-7000-beef-000000000002
  17. - name: start
  18. in: query
  19. required: false
  20. description: Start date (ISO 8601) to filter sessions (on start_time). Beginning of time if omitted.
  21. schema:
  22. type: string
  23. format: date-time
  24. example: '2026-01-01T00:00:00Z'
  25. - name: end
  26. in: query
  27. required: false
  28. description: End date (ISO 8601) to filter sessions (on start_time). End of time if omitted.
  29. schema:
  30. type: string
  31. format: date-time
  32. example: '2026-12-31T23:59:59Z'
  33. - name: page
  34. in: query
  35. required: false
  36. description: 1-indexed page number for pagination (defaults to 1). Returns up to 50 results per page.
  37. schema:
  38. type: integer
  39. example: 1
  40. responses:
  41. '200':
  42. description: List of matching sessions plus total count for pagination.
  43. content:
  44. application/json:
  45. schema:
  46. type: object
  47. required:
  48. - sessions
  49. - total
  50. properties:
  51. sessions:
  52. type: array
  53. items:
  54. $ref: '../components/schemas/Session.yaml'
  55. total:
  56. type: integer
  57. description: Total number of sessions matching the query (for the workout).
  58. example: 12
  59. example:
  60. sessions:
  61. - id: 0191a23b-dead-7000-beef-000000000005
  62. workout: 0191a23b-dead-7000-beef-000000000002
  63. start_time: '2026-01-15T09:00:00Z'
  64. end_time: '2026-01-15T09:45:00Z'
  65. - id: 0191a23b-dead-7000-beef-000000000008
  66. workout: 0191a23b-dead-7000-beef-000000000002
  67. start_time: '2026-01-10T10:00:00Z'
  68. end_time: '2026-01-10T10:30:00Z'
  69. total: 12
  70. '400':
  71. description: Invalid query parameter (e.g. bad date format).
  72. content:
  73. application/json:
  74. schema:
  75. $ref: '../components/schemas/ErrorResponse.yaml'
  76. example:
  77. error: Invalid start date
  78. '401':
  79. description: Missing or invalid auth token.
  80. content:
  81. application/json:
  82. schema:
  83. $ref: '../components/schemas/ErrorResponse.yaml'
  84. examples:
  85. missing:
  86. summary: No cookie present
  87. value:
  88. error: Missing auth token
  89. invalid:
  90. summary: Token invalid or expired
  91. value:
  92. error: Invalid auth token
  93. '403':
  94. description: Authenticated user does not own this workout.
  95. content:
  96. application/json:
  97. schema:
  98. $ref: '../components/schemas/ErrorResponse.yaml'
  99. example:
  100. error: You do not have permission to access this workout
  101. '404':
  102. description: Workout not found.
  103. content:
  104. application/json:
  105. schema:
  106. $ref: '../components/schemas/ErrorResponse.yaml'
  107. example:
  108. error: Workout not found
  109. '500':
  110. description: Internal server error.
  111. content:
  112. application/json:
  113. schema:
  114. $ref: '../components/schemas/ErrorResponse.yaml'
  115. post:
  116. summary: Create a new session (after completing the workout on the front-end)
  117. operationId: createWorkoutSession
  118. tags:
  119. - Sessions
  120. security:
  121. - cookieAuth: []
  122. parameters:
  123. - name: workout_id
  124. in: path
  125. required: true
  126. description: UUID of the workout this session belongs to.
  127. schema:
  128. type: string
  129. format: uuid
  130. example: 0191a23b-dead-7000-beef-000000000002
  131. requestBody:
  132. required: true
  133. content:
  134. application/json:
  135. schema:
  136. type: object
  137. required:
  138. - start_time
  139. - end_time
  140. - exercises
  141. properties:
  142. start_time:
  143. type: string
  144. format: date-time
  145. description: ISO 8601 timestamp when the session started.
  146. example: '2026-01-15T09:00:00Z'
  147. end_time:
  148. type: string
  149. format: date-time
  150. description: ISO 8601 timestamp when the session ended.
  151. example: '2026-01-15T09:45:00Z'
  152. exercises:
  153. type: array
  154. description: List of completed exercises with what was actually performed.
  155. items:
  156. type: object
  157. required:
  158. - exercise_id
  159. properties:
  160. exercise_id:
  161. type: string
  162. format: uuid
  163. description: ID of the original exercise definition from the workout.
  164. example: 0191a23b-dead-7000-beef-000000000003
  165. sets:
  166. type: array
  167. nullable: true
  168. description: Array of sets performed for this exercise. Each set can include reps/weight for strength or duration/distance for cardio.
  169. items:
  170. $ref: '../components/schemas/SessionSet.yaml'
  171. example:
  172. start_time: '2026-01-15T09:00:00Z'
  173. end_time: '2026-01-15T09:45:00Z'
  174. exercises:
  175. - exercise_id: 0191a23b-dead-7000-beef-000000000003
  176. sets:
  177. - reps: 12
  178. weight: 120
  179. - reps: 11
  180. weight: 120
  181. - reps: 10
  182. weight: 120
  183. - exercise_id: 0191a23b-dead-7000-beef-000000000004
  184. sets:
  185. - reps: 15
  186. - reps: 12
  187. responses:
  188. '201':
  189. description: Session created successfully. Returns the generated session ID.
  190. content:
  191. application/json:
  192. schema:
  193. type: object
  194. required:
  195. - id
  196. properties:
  197. id:
  198. type: string
  199. format: uuid
  200. example: 0191a23b-dead-7000-beef-000000000005
  201. '400':
  202. description: Invalid request body.
  203. content:
  204. application/json:
  205. schema:
  206. $ref: '../components/schemas/ErrorResponse.yaml'
  207. example:
  208. error: Invalid request body. Please check your data and try again.
  209. '401':
  210. description: Missing or invalid auth token.
  211. content:
  212. application/json:
  213. schema:
  214. $ref: '../components/schemas/ErrorResponse.yaml'
  215. examples:
  216. missing:
  217. summary: No cookie present
  218. value:
  219. error: Missing auth token
  220. invalid:
  221. summary: Token invalid or expired
  222. value:
  223. error: Invalid auth token
  224. '403':
  225. description: Authenticated user does not own this workout.
  226. content:
  227. application/json:
  228. schema:
  229. $ref: '../components/schemas/ErrorResponse.yaml'
  230. example:
  231. error: You do not have permission to access this workout
  232. '404':
  233. description: Workout or exercise not found.
  234. content:
  235. application/json:
  236. schema:
  237. $ref: '../components/schemas/ErrorResponse.yaml'
  238. example:
  239. error: Workout not found
  240. '422':
  241. description: One of the exercises does not belong to the workout.
  242. content:
  243. application/json:
  244. schema:
  245. $ref: '../components/schemas/ErrorResponse.yaml'
  246. example:
  247. error: Exercise does not belong to this workout
  248. '500':
  249. description: Internal server error.
  250. content:
  251. application/json:
  252. schema:
  253. $ref: '../components/schemas/ErrorResponse.yaml'