Line data Source code
1 4 : (ns schemas.api.stages
2 : (:require
3 : [schemas.api.common :as api-common-schemas]
4 : [schemas.domain.advancements :as advancement-schemas]
5 : [schemas.types :as types-schemas]))
6 :
7 :
8 : ;; Request Schemas
9 4 : (def StageRequestSchema
10 28 : [:map {:swagger/title "StageRequestSchema"
11 : :swagger/description "Request payload for creating or updating a stage"}
12 8 : [:name
13 44 : [:string {:min 1
14 : :max 255
15 : :description "Stage name"
16 : :example "Group Stage"}]]
17 20 : [:order {:optional true}
18 8 : [:maybe
19 36 : [:int {:min 1
20 : :description "Stage order within class"
21 : :example 1}]]]
22 20 : [:state {:optional true}
23 8 : [:maybe
24 28 : [:string {:description "Stage state"
25 : :example "pending"}]]]
26 20 : [:ruleset-id {:optional true}
27 20 : [:maybe [:ref :types/UuidString]]]
28 20 : [:config {:optional true}
29 24 : [:maybe [:map-of :keyword :any]]]])
30 :
31 :
32 : ;; Path Params Schemas
33 4 : (def ClassUuidPathParamsSchema
34 20 : [:map {:swagger/title "ClassUuidPathParamsSchema"}
35 28 : [:class-uuid {:description "Class UUID in v4 format"
36 : :example "550e8400-e29b-41d4-a716-446655440000"}
37 4 : types-schemas/UuidString]])
38 :
39 :
40 4 : (def StageAndClassPathParamsSchema
41 20 : [:map {:swagger/title "StageAndClassPathParamsSchema"}
42 28 : [:class-uuid {:description "Class UUID in v4 format"
43 : :example "550e8400-e29b-41d4-a716-446655440000"}
44 4 : types-schemas/UuidString]
45 28 : [:stage-uuid {:description "Stage UUID in v4 format"
46 : :example "550e8400-e29b-41d4-a716-446655440000"}
47 4 : types-schemas/UuidString]])
48 :
49 :
50 : ;; Response Body Schemas
51 4 : (def StageResponseSuccess200Body
52 28 : [:map {:swagger/title "StageResponseSuccess200Body"
53 : :swagger/description "Successful stage retrieval/update response"}
54 28 : [:message [:string {:example "Stage updated successfully."}]]
55 20 : [:data [:ref :domain/StageRecord]]])
56 :
57 :
58 4 : (def StageResponseSuccess201Body
59 28 : [:map {:swagger/title "StageResponseSuccess201Body"
60 : :swagger/description "Successful stage creation response"}
61 28 : [:message [:string {:example "Stage created successfully."}]]
62 20 : [:data [:ref :domain/StageRecord]]])
63 :
64 :
65 4 : (def StageListResponseSuccess200Body
66 28 : [:map {:swagger/title "StageListResponseSuccess200Body"
67 : :swagger/description "Successful stages list retrieval response"}
68 28 : [:message [:string {:example "Stages retrieved successfully."}]]
69 28 : [:data [:sequential [:ref :domain/StageRecord]]]])
70 :
71 :
72 4 : (def StageResponseError400Body
73 28 : [:map {:swagger/title "StageResponseError400Body"
74 : :swagger/description "Stage operation error response"}
75 28 : [:message [:string {:example "Invalid stage data."}]]
76 12 : [:data nil?]])
77 :
78 :
79 4 : (def StageResponseError404Body
80 28 : [:map {:swagger/title "StageResponseError404Body"
81 : :swagger/description "Stage not found response"}
82 28 : [:message [:string {:example "Stage not found."}]]
83 20 : [:data {:optional true}
84 4 : nil?]])
85 :
86 :
87 4 : (def StageDeleteResponseSuccess200Body
88 28 : [:map {:swagger/title "StageDeleteResponseSuccess200Body"
89 : :swagger/description "Successful stage deletion response"}
90 28 : [:message [:string {:example "Stage deleted successfully."}]]])
91 :
92 :
93 : ;; Response Schemas
94 4 : (def StageResponseSchema
95 : "Union of possible stage create/update responses."
96 8 : [:or
97 40 : [:map [:status [:= 200]] [:body StageResponseSuccess200Body]]
98 40 : [:map [:status [:= 201]] [:body StageResponseSuccess201Body]]
99 40 : [:map [:status [:= 400]] [:body StageResponseError400Body]]
100 40 : [:map [:status [:= 404]] [:body StageResponseError404Body]]])
101 :
102 :
103 4 : (def StageListResponseSchema
104 : "Response for listing stages by class."
105 8 : [:or
106 40 : [:map [:status [:= 200]] [:body StageListResponseSuccess200Body]]
107 40 : [:map [:status [:= 400]] [:body StageResponseError400Body]]])
108 :
109 :
110 4 : (def StageDeleteResponseSchema
111 : "Response for deleting a stage."
112 8 : [:or
113 40 : [:map [:status [:= 200]] [:body StageDeleteResponseSuccess200Body]]
114 40 : [:map [:status [:= 404]] [:body StageResponseError404Body]]])
115 :
116 :
117 : ;; By-template request/response schemas
118 :
119 :
120 4 : (def StageByTemplateRequestSchema
121 28 : [:map {:swagger/title "StageByTemplateRequestSchema"
122 : :swagger/description "Request payload for creating stages from a template"}
123 8 : [:template-type
124 8 : (into
125 28 : [:enum {:description "Template type"
126 : :example "groups_monrad"}]
127 4 : api-common-schemas/stages-template-type-options)]
128 20 : [:qualification-draw-name {:optional true}
129 8 : [:maybe
130 44 : [:string {:min 1
131 : :max 255
132 : :description "Qualification draw name"
133 : :example "Qualification stage"}]]]
134 20 : [:main-draw-name {:optional true}
135 8 : [:maybe
136 44 : [:string {:min 1
137 : :max 255
138 : :description "Main draw name"
139 : :example "Main draw"}]]]
140 20 : [:groups-count {:optional true}
141 8 : [:maybe
142 36 : [:int {:min 1
143 : :description "Number of groups (required for groups_* templates)"
144 : :example 4}]]]
145 20 : [:group-size {:optional true}
146 8 : [:maybe
147 36 : [:int {:min 1
148 : :description "Players per group (required for groups_* templates)"
149 : :example 4}]]]
150 20 : [:players-count {:optional true}
151 8 : [:maybe
152 36 : [:int {:min 1
153 : :description "Total players for a monrad bracket (required for the monrad template)"
154 : :example 16}]]]
155 20 : [:players-count-advancing {:optional true}
156 8 : [:maybe
157 36 : [:int {:min 1
158 : :description
159 : "Players advancing to main draw per group. Omit for 'all places' groups_monrad."
160 : :example 2}]]]
161 20 : [:with-consolation {:optional true}
162 8 : [:maybe
163 8 : [:boolean
164 20 : {:description
165 : "When true, creates an additional consolation monrad bracket in stage 2 for groups_monrad top-n (requires players-count-advancing)"
166 : :example true}]]]
167 20 : [:consolation-from {:optional true}
168 8 : [:maybe
169 8 : [:int
170 28 : {:min 1
171 : :description
172 : "Starting rank (inclusive) within each group that feeds the consolation draw. Must be > players-count-advancing"
173 : :example 3}]]]
174 20 : [:consolation-to {:optional true}
175 8 : [:maybe
176 36 : [:int {:min 1
177 : :description "Ending rank (inclusive) within each group that feeds the consolation draw"
178 : :example 4}]]]
179 20 : [:consolation {:optional true}
180 8 : [:maybe
181 8 : [:boolean
182 20 : {:description
183 : "When true, creates a consolation group draw for eliminated players (qualification_monrad only)"
184 : :example true}]]]])
185 :
186 :
187 4 : (def StagesByTemplateResponseSuccess201Body
188 28 : [:map {:swagger/title "StagesByTemplateResponseSuccess201Body"
189 : :swagger/description "Successful stages creation from template response"}
190 28 : [:message [:string {:example "Stages created successfully."}]]
191 8 : [:data
192 8 : [:map
193 20 : [:qualification-stage {:optional true}
194 12 : [:ref :domain/StageRecord]]
195 20 : [:main-draw-stage [:ref :domain/StageRecord]]]]])
196 :
197 :
198 4 : (def StagesByTemplateResponseSchema
199 : "Response for creating stages by template."
200 8 : [:or
201 40 : [:map [:status [:= 201]] [:body StagesByTemplateResponseSuccess201Body]]
202 40 : [:map [:status [:= 400]] [:body StageResponseError400Body]]
203 40 : [:map [:status [:= 404]] [:body StageResponseError404Body]]])
204 :
205 :
206 4 : (def StagePlayResponseSuccess200Body
207 28 : [:map {:swagger/title "StagePlayResponseSuccess200Body"
208 : :swagger/description "Successful stage play response"}
209 28 : [:message [:string {:example "Stage played successfully."}]]
210 36 : [:data [:map [:advancements [:sequential advancement-schemas/AdvancementRecordSchema]]]]])
211 :
212 :
213 4 : (def StagePlayResponseSchema
214 : "Response for playing a stage (marking complete + generating advancements)."
215 8 : [:or
216 40 : [:map [:status [:= 200]] [:body StagePlayResponseSuccess200Body]]
217 40 : [:map [:status [:= 400]] [:body StageResponseError400Body]]
218 40 : [:map [:status [:= 404]] [:body StageResponseError404Body]]])
|