Line data Source code
1 4 : (ns schemas.api.groups
2 : (:require
3 : [schemas.types :as types-schemas]))
4 :
5 :
6 : ;; Request Schemas
7 4 : (def GroupRequestSchema
8 28 : [:map {:swagger/title "GroupRequestSchema"
9 : :swagger/description "Request payload for creating or updating a group"}
10 8 : [:name
11 44 : [:string {:min 1
12 : :max 255
13 : :description "Group name"
14 : :example "Group A"}]]
15 20 : [:order {:optional true}
16 8 : [:maybe
17 36 : [:int {:min 1
18 : :description "Group order within draw"
19 : :example 1}]]]
20 20 : [:config {:optional true}
21 12 : [:maybe :map]]
22 20 : [:ruleset-id {:optional true}
23 12 : [:maybe types-schemas/UuidString]]])
24 :
25 :
26 : ;; Path Params Schemas
27 4 : (def DrawUuidPathParamsSchema
28 20 : [:map {:swagger/title "DrawUuidPathParamsSchema"}
29 28 : [:draw-uuid {:description "Draw UUID in v4 format"
30 : :example "550e8400-e29b-41d4-a716-446655440000"}
31 4 : types-schemas/UuidString]])
32 :
33 :
34 4 : (def GroupAndDrawPathParamsSchema
35 20 : [:map {:swagger/title "GroupAndDrawPathParamsSchema"}
36 28 : [:draw-uuid {:description "Draw UUID in v4 format"
37 : :example "550e8400-e29b-41d4-a716-446655440000"}
38 4 : types-schemas/UuidString]
39 28 : [:group-uuid {:description "Group UUID in v4 format"
40 : :example "550e8400-e29b-41d4-a716-446655440000"}
41 4 : types-schemas/UuidString]])
42 :
43 :
44 : ;; Response Body Schemas
45 4 : (def GroupResponseSuccess200Body
46 28 : [:map {:swagger/title "GroupResponseSuccess200Body"
47 : :swagger/description "Successful group retrieval/update response"}
48 28 : [:message [:string {:example "Group updated successfully."}]]
49 20 : [:data [:ref :domain/GroupRecord]]])
50 :
51 :
52 4 : (def GroupResponseSuccess201Body
53 28 : [:map {:swagger/title "GroupResponseSuccess201Body"
54 : :swagger/description "Successful group creation response"}
55 28 : [:message [:string {:example "Group created successfully."}]]
56 20 : [:data [:ref :domain/GroupRecord]]])
57 :
58 :
59 4 : (def GroupListResponseSuccess200Body
60 28 : [:map {:swagger/title "GroupListResponseSuccess200Body"
61 : :swagger/description "Successful groups list retrieval response"}
62 28 : [:message [:string {:example "Groups retrieved successfully."}]]
63 28 : [:data [:sequential [:ref :domain/GroupRecord]]]])
64 :
65 :
66 4 : (def GroupResponseError400Body
67 28 : [:map {:swagger/title "GroupResponseError400Body"
68 : :swagger/description "Group operation error response"}
69 28 : [:message [:string {:example "Invalid group data."}]]
70 12 : [:data nil?]])
71 :
72 :
73 4 : (def GroupResponseError404Body
74 28 : [:map {:swagger/title "GroupResponseError404Body"
75 : :swagger/description "Group not found response"}
76 28 : [:message [:string {:example "Group not found."}]]
77 20 : [:data {:optional true}
78 4 : nil?]])
79 :
80 :
81 4 : (def GroupDeleteResponseSuccess200Body
82 28 : [:map {:swagger/title "GroupDeleteResponseSuccess200Body"
83 : :swagger/description "Successful group deletion response"}
84 28 : [:message [:string {:example "Group deleted successfully."}]]])
85 :
86 :
87 : ;; Response Schemas
88 4 : (def GroupResponseSchema
89 : "Union of possible group create/update responses."
90 8 : [:or
91 40 : [:map [:status [:= 200]] [:body GroupResponseSuccess200Body]]
92 40 : [:map [:status [:= 201]] [:body GroupResponseSuccess201Body]]
93 40 : [:map [:status [:= 400]] [:body GroupResponseError400Body]]
94 40 : [:map [:status [:= 404]] [:body GroupResponseError404Body]]])
95 :
96 :
97 4 : (def GroupListResponseSchema
98 : "Response for listing groups by draw."
99 8 : [:or
100 40 : [:map [:status [:= 200]] [:body GroupListResponseSuccess200Body]]
101 40 : [:map [:status [:= 400]] [:body GroupResponseError400Body]]])
102 :
103 :
104 4 : (def GroupDeleteResponseSchema
105 : "Response for deleting a group."
106 8 : [:or
107 40 : [:map [:status [:= 200]] [:body GroupDeleteResponseSuccess200Body]]
108 40 : [:map [:status [:= 404]] [:body GroupResponseError404Body]]])
109 :
110 :
111 : ;; Shared participants response body (list of GroupParticipantRecord)
112 4 : (def GroupParticipantsResponseSuccess200Body
113 28 : [:map {:swagger/title "GroupParticipantsResponseSuccess200Body"
114 : :swagger/description "Successful group participants response"}
115 28 : [:message [:string {:example "Group participants updated successfully."}]]
116 28 : [:data [:sequential [:ref :domain/GroupParticipantRecord]]]])
117 :
118 :
119 4 : (def GroupParticipantsResponseError500Body
120 28 : [:map {:swagger/title "GroupParticipantsResponseError500Body"
121 : :swagger/description "Group participants operation failure response"}
122 28 : [:message [:string {:example "Failed to update group participants."}]]
123 12 : [:data nil?]])
124 :
125 :
126 : ;; --- Fill participants (PUT /participants) ---
127 4 : (def GroupParticipantsSetRequestSchema
128 28 : [:map {:swagger/title "GroupParticipantsSetRequestSchema"
129 : :swagger/description
130 : "Request payload for filling empty group participant slots with a provided list"}
131 20 : [:participant-ids {:optional true}
132 20 : [:maybe [:sequential types-schemas/UuidString]]]])
133 :
134 :
135 4 : (def GroupParticipantsSetResponseSchema
136 : "Response for filling empty group participant slots."
137 8 : [:or
138 40 : [:map [:status [:= 200]] [:body GroupParticipantsResponseSuccess200Body]]
139 40 : [:map [:status [:= 400]] [:body GroupResponseError400Body]]
140 40 : [:map [:status [:= 404]] [:body GroupResponseError404Body]]
141 40 : [:map [:status [:= 500]] [:body GroupParticipantsResponseError500Body]]])
142 :
143 :
144 : ;; --- Fill from class (POST /participants/fill) ---
145 4 : (def GroupParticipantsFillResponseSchema
146 : "Response for filling group participants from class."
147 8 : [:or
148 40 : [:map [:status [:= 200]] [:body GroupParticipantsResponseSuccess200Body]]
149 40 : [:map [:status [:= 400]] [:body GroupResponseError400Body]]
150 40 : [:map [:status [:= 404]] [:body GroupResponseError404Body]]
151 40 : [:map [:status [:= 500]] [:body GroupParticipantsResponseError500Body]]])
152 :
153 :
154 4 : (def GroupParticipantsFillAllResponseSchema
155 : "Response for filling all draw group participants from class."
156 8 : [:or
157 40 : [:map [:status [:= 200]] [:body GroupParticipantsResponseSuccess200Body]]
158 40 : [:map [:status [:= 400]] [:body GroupResponseError400Body]]
159 40 : [:map [:status [:= 404]] [:body GroupResponseError404Body]]
160 40 : [:map [:status [:= 500]] [:body GroupParticipantsResponseError500Body]]])
161 :
162 :
163 : ;; --- Update single participant (PUT /participants/:group-participant-uuid) ---
164 4 : (def GroupParticipantUuidPathParamsSchema
165 20 : [:map {:swagger/title "GroupParticipantUuidPathParamsSchema"}
166 28 : [:draw-uuid {:description "Draw UUID"
167 : :example "550e8400-e29b-41d4-a716-446655440000"}
168 4 : types-schemas/UuidString]
169 28 : [:group-uuid {:description "Group UUID"
170 : :example "550e8400-e29b-41d4-a716-446655440000"}
171 4 : types-schemas/UuidString]
172 28 : [:group-participant-uuid {:description "Group participant UUID"
173 : :example "550e8400-e29b-41d4-a716-446655440000"}
174 4 : types-schemas/UuidString]])
175 :
176 :
177 4 : (def GroupParticipantUpdateRequestSchema
178 28 : [:map {:swagger/title "GroupParticipantUpdateRequestSchema"
179 : :swagger/description "Request payload for updating a single group participant"}
180 20 : [:participant-uuid {:optional true}
181 12 : [:maybe types-schemas/UuidString]]
182 20 : [:status {:optional true}
183 8 : [:maybe
184 28 : [:string {:description "Participant status"
185 : :example "active"}]]]
186 20 : [:slot {:optional true}
187 8 : [:maybe
188 36 : [:int {:min 1
189 : :description "Slot position"
190 : :example 1}]]]])
191 :
192 :
193 4 : (def GroupParticipantUpdateResponseSuccess200Body
194 28 : [:map {:swagger/title "GroupParticipantUpdateResponseSuccess200Body"
195 : :swagger/description "Successful single group participant update response"}
196 28 : [:message [:string {:example "Group participant updated successfully."}]]
197 20 : [:data [:ref :domain/GroupParticipantRecord]]])
198 :
199 :
200 4 : (def GroupParticipantUpdateResponseSchema
201 : "Response for updating a single group participant."
202 8 : [:or
203 40 : [:map [:status [:= 200]] [:body GroupParticipantUpdateResponseSuccess200Body]]
204 40 : [:map [:status [:= 400]] [:body GroupResponseError400Body]]
205 40 : [:map [:status [:= 404]] [:body GroupResponseError404Body]]
206 40 : [:map [:status [:= 500]] [:body GroupParticipantsResponseError500Body]]])
|