Line data Source code
1 4 : (ns schemas.api.brackets
2 : (:require
3 : [schemas.types :as types-schemas]))
4 :
5 :
6 : ;; Request Schemas
7 4 : (def BracketRequestSchema
8 28 : [:map {:swagger/title "BracketRequestSchema"
9 : :swagger/description "Request payload for creating or updating a bracket"}
10 8 : [:name
11 44 : [:string {:min 1
12 : :max 255
13 : :description "Bracket name"
14 : :example "Winners Bracket"}]]
15 20 : [:type {:optional true}
16 8 : [:maybe
17 28 : [:string {:description "Bracket type"
18 : :example "winners"}]]]
19 20 : [:config {:optional true}
20 12 : [:maybe :map]]
21 20 : [:ruleset-id {:optional true}
22 12 : [:maybe types-schemas/UuidString]]])
23 :
24 :
25 : ;; Path Params Schemas
26 4 : (def BracketDrawUuidPathParamsSchema
27 20 : [:map {:swagger/title "BracketDrawUuidPathParamsSchema"}
28 28 : [:draw-uuid {:description "Draw UUID in v4 format"
29 : :example "550e8400-e29b-41d4-a716-446655440000"}
30 4 : types-schemas/UuidString]])
31 :
32 :
33 4 : (def BracketAndDrawPathParamsSchema
34 20 : [:map {:swagger/title "BracketAndDrawPathParamsSchema"}
35 28 : [:draw-uuid {:description "Draw UUID in v4 format"
36 : :example "550e8400-e29b-41d4-a716-446655440000"}
37 4 : types-schemas/UuidString]
38 28 : [:bracket-uuid {:description "Bracket UUID in v4 format"
39 : :example "550e8400-e29b-41d4-a716-446655440000"}
40 4 : types-schemas/UuidString]])
41 :
42 :
43 : ;; Response Body Schemas
44 4 : (def BracketResponseSuccess200Body
45 28 : [:map {:swagger/title "BracketResponseSuccess200Body"
46 : :swagger/description "Successful bracket retrieval/update response"}
47 28 : [:message [:string {:example "Bracket updated successfully."}]]
48 20 : [:data [:ref :domain/BracketRecord]]])
49 :
50 :
51 4 : (def BracketResponseSuccess201Body
52 28 : [:map {:swagger/title "BracketResponseSuccess201Body"
53 : :swagger/description "Successful bracket creation response"}
54 28 : [:message [:string {:example "Bracket created successfully."}]]
55 20 : [:data [:ref :domain/BracketRecord]]])
56 :
57 :
58 4 : (def BracketListResponseSuccess200Body
59 28 : [:map {:swagger/title "BracketListResponseSuccess200Body"
60 : :swagger/description "Successful brackets list retrieval response"}
61 28 : [:message [:string {:example "Brackets retrieved successfully."}]]
62 28 : [:data [:sequential [:ref :domain/BracketRecord]]]])
63 :
64 :
65 4 : (def BracketResponseError400Body
66 28 : [:map {:swagger/title "BracketResponseError400Body"
67 : :swagger/description "Bracket operation error response"}
68 28 : [:message [:string {:example "Invalid bracket data."}]]
69 12 : [:data nil?]])
70 :
71 :
72 4 : (def BracketResponseError404Body
73 28 : [:map {:swagger/title "BracketResponseError404Body"
74 : :swagger/description "Bracket not found response"}
75 28 : [:message [:string {:example "Bracket not found."}]]
76 20 : [:data {:optional true}
77 4 : nil?]])
78 :
79 :
80 4 : (def BracketDeleteResponseSuccess200Body
81 28 : [:map {:swagger/title "BracketDeleteResponseSuccess200Body"
82 : :swagger/description "Successful bracket deletion response"}
83 28 : [:message [:string {:example "Bracket deleted successfully."}]]])
84 :
85 :
86 : ;; Response Schemas
87 4 : (def BracketResponseSchema
88 : "Union of possible bracket create/update responses."
89 8 : [:or
90 40 : [:map [:status [:= 200]] [:body BracketResponseSuccess200Body]]
91 40 : [:map [:status [:= 201]] [:body BracketResponseSuccess201Body]]
92 40 : [:map [:status [:= 400]] [:body BracketResponseError400Body]]
93 40 : [:map [:status [:= 404]] [:body BracketResponseError404Body]]])
94 :
95 :
96 4 : (def BracketListResponseSchema
97 : "Response for listing brackets by draw."
98 8 : [:or
99 40 : [:map [:status [:= 200]] [:body BracketListResponseSuccess200Body]]
100 40 : [:map [:status [:= 400]] [:body BracketResponseError400Body]]])
101 :
102 :
103 4 : (def BracketDeleteResponseSchema
104 : "Response for deleting a bracket."
105 8 : [:or
106 40 : [:map [:status [:= 200]] [:body BracketDeleteResponseSuccess200Body]]
107 40 : [:map [:status [:= 404]] [:body BracketResponseError404Body]]])
108 :
109 :
110 : ;; --- Fill participants from class (POST /brackets/participants/fill) ---
111 4 : (def BracketParticipantsFillResponseSuccess200Body
112 28 : [:map {:swagger/title "BracketParticipantsFillResponseSuccess200Body"
113 : :swagger/description "Successful bracket participants fill response"}
114 28 : [:message [:string {:example "Bracket participants filled successfully."}]]
115 28 : [:data [:sequential [:ref :domain/BracketMatchSlotRecord]]]])
116 :
117 :
118 4 : (def BracketParticipantsFillResponseError500Body
119 28 : [:map {:swagger/title "BracketParticipantsFillResponseError500Body"
120 : :swagger/description "Bracket participants fill failure response"}
121 28 : [:message [:string {:example "Failed to fill bracket participants."}]]
122 12 : [:data nil?]])
123 :
124 :
125 4 : (def BracketParticipantsFillResponseSchema
126 : "Response for filling the main bracket's first-round seed slots from class participants."
127 8 : [:or
128 40 : [:map [:status [:= 200]] [:body BracketParticipantsFillResponseSuccess200Body]]
129 40 : [:map [:status [:= 400]] [:body BracketResponseError400Body]]
130 40 : [:map [:status [:= 404]] [:body BracketResponseError404Body]]
131 40 : [:map [:status [:= 500]] [:body BracketParticipantsFillResponseError500Body]]])
132 :
133 :
134 : ;; --- Substitute participant in a slot (PUT /brackets/participants/:bracket-match-slot-uuid) ---
135 4 : (def BracketParticipantSubstituteRequestSchema
136 28 : [:map {:swagger/title "BracketParticipantSubstituteRequestSchema"
137 : :swagger/description "Request payload for substituting a bracket match slot participant"}
138 20 : [:participant-uuid {:optional false}
139 12 : [:maybe types-schemas/UuidString]]])
140 :
141 :
142 4 : (def BracketParticipantSubstitutePathParamsSchema
143 20 : [:map {:swagger/title "BracketParticipantSubstitutePathParamsSchema"}
144 20 : [:draw-uuid {:description "Draw UUID"}
145 4 : types-schemas/UuidString]
146 20 : [:bracket-match-slot-uuid {:description "Bracket match slot UUID"}
147 4 : types-schemas/UuidString]])
148 :
149 :
150 4 : (def BracketParticipantSubstituteResponseSuccess200Body
151 28 : [:map {:swagger/title "BracketParticipantSubstituteResponseSuccess200Body"
152 : :swagger/description "Successful bracket slot substitution response"}
153 28 : [:message [:string {:example "Bracket slot participant substituted successfully."}]]
154 20 : [:data [:ref :domain/BracketMatchSlotRecord]]])
155 :
156 :
157 4 : (def BracketParticipantSubstituteResponseError500Body
158 28 : [:map {:swagger/title "BracketParticipantSubstituteResponseError500Body"
159 : :swagger/description "Bracket slot substitution failure response"}
160 28 : [:message [:string {:example "Failed to update bracket slot."}]]
161 12 : [:data nil?]])
162 :
163 :
164 4 : (def BracketParticipantSubstituteResponseSchema
165 : "Response for substituting a participant in a bracket match slot."
166 8 : [:or
167 40 : [:map [:status [:= 200]] [:body BracketParticipantSubstituteResponseSuccess200Body]]
168 40 : [:map [:status [:= 400]] [:body BracketResponseError400Body]]
169 40 : [:map [:status [:= 404]] [:body BracketResponseError404Body]]
170 40 : [:map [:status [:= 500]] [:body BracketParticipantSubstituteResponseError500Body]]])
171 :
172 :
173 : ;; --- Add participant to an empty slot (POST /brackets/participants/:bracket-match-slot-uuid) ---
174 4 : (def BracketParticipantAddRequestSchema
175 28 : [:map {:swagger/title "BracketParticipantAddRequestSchema"
176 : :swagger/description "Request payload for adding a participant to an empty bracket slot"}
177 20 : [:participant-uuid {:optional false}
178 4 : types-schemas/UuidString]])
179 :
180 :
181 4 : (def BracketParticipantAddPathParamsSchema
182 20 : [:map {:swagger/title "BracketParticipantAddPathParamsSchema"}
183 20 : [:draw-uuid {:description "Draw UUID"}
184 4 : types-schemas/UuidString]
185 20 : [:bracket-match-slot-uuid {:description "Bracket match slot UUID"}
186 4 : types-schemas/UuidString]])
187 :
188 :
189 4 : (def BracketParticipantAddResponseSuccess200Body
190 28 : [:map {:swagger/title "BracketParticipantAddResponseSuccess200Body"
191 : :swagger/description "Successful bracket slot participant add response"}
192 28 : [:message [:string {:example "Bracket slot participant added successfully."}]]
193 20 : [:data [:ref :domain/BracketMatchSlotRecord]]])
194 :
195 :
196 4 : (def BracketParticipantAddResponseError500Body
197 28 : [:map {:swagger/title "BracketParticipantAddResponseError500Body"
198 : :swagger/description "Bracket slot participant add failure response"}
199 28 : [:message [:string {:example "Failed to add bracket slot participant."}]]
200 12 : [:data nil?]])
201 :
202 :
203 4 : (def BracketParticipantAddResponseSchema
204 : "Response for adding a participant to a bracket match slot."
205 8 : [:or
206 40 : [:map [:status [:= 200]] [:body BracketParticipantAddResponseSuccess200Body]]
207 40 : [:map [:status [:= 400]] [:body BracketResponseError400Body]]
208 40 : [:map [:status [:= 404]] [:body BracketResponseError404Body]]
209 40 : [:map [:status [:= 500]] [:body BracketParticipantAddResponseError500Body]]])
|