Line data Source code
1 4 : (ns schemas.api.draws
2 : (:require
3 : [schemas.types :as types-schemas]))
4 :
5 :
6 : ;; Request Schemas
7 4 : (def DrawRequestSchema
8 28 : [:map {:swagger/title "DrawRequestSchema"
9 : :swagger/description "Request payload for creating or updating a draw"}
10 20 : [:name {:optional true}
11 8 : [:maybe
12 44 : [:string {:min 1
13 : :max 255
14 : :description "Draw name"
15 : :example "Group Draw"}]]]
16 20 : [:order {:optional true}
17 8 : [:maybe
18 36 : [:int {:min 1
19 : :description "Draw order within stage"
20 : :example 1}]]]
21 20 : [:type {:optional true}
22 8 : [:maybe
23 28 : [:string {:description "Draw type"
24 : :example "group"}]]]
25 20 : [:config {:optional true}
26 24 : [:maybe [:map-of :keyword :any]]]
27 20 : [:ruleset-id {:optional true}
28 12 : [:maybe types-schemas/UuidString]]])
29 :
30 :
31 : ;; Path Params Schemas
32 4 : (def StageUuidPathParamsSchema
33 20 : [:map {:swagger/title "StageUuidPathParamsSchema"}
34 28 : [:stage-uuid {:description "Stage UUID in v4 format"
35 : :example "550e8400-e29b-41d4-a716-446655440000"}
36 4 : types-schemas/UuidString]])
37 :
38 :
39 4 : (def DrawAndStagePathParamsSchema
40 20 : [:map {:swagger/title "DrawAndStagePathParamsSchema"}
41 28 : [:stage-uuid {:description "Stage UUID in v4 format"
42 : :example "550e8400-e29b-41d4-a716-446655440000"}
43 4 : types-schemas/UuidString]
44 28 : [:draw-uuid {:description "Draw UUID in v4 format"
45 : :example "550e8400-e29b-41d4-a716-446655440000"}
46 4 : types-schemas/UuidString]])
47 :
48 :
49 : ;; Response Body Schemas
50 4 : (def DrawResponseSuccess200Body
51 28 : [:map {:swagger/title "DrawResponseSuccess200Body"
52 : :swagger/description "Successful draw retrieval/update response"}
53 28 : [:message [:string {:example "Draw updated successfully."}]]
54 20 : [:data [:ref :domain/DrawRecord]]])
55 :
56 :
57 4 : (def DrawResponseSuccess201Body
58 28 : [:map {:swagger/title "DrawResponseSuccess201Body"
59 : :swagger/description "Successful draw creation response"}
60 28 : [:message [:string {:example "Draw created successfully."}]]
61 20 : [:data [:ref :domain/DrawRecord]]])
62 :
63 :
64 4 : (def DrawListResponseSuccess200Body
65 28 : [:map {:swagger/title "DrawListResponseSuccess200Body"
66 : :swagger/description "Successful draws list retrieval response"}
67 28 : [:message [:string {:example "Draws retrieved successfully."}]]
68 28 : [:data [:sequential [:ref :domain/DrawRecord]]]])
69 :
70 :
71 4 : (def DrawResponseError400Body
72 28 : [:map {:swagger/title "DrawResponseError400Body"
73 : :swagger/description "Draw operation error response"}
74 28 : [:message [:string {:example "Invalid draw data."}]]
75 12 : [:data nil?]])
76 :
77 :
78 4 : (def DrawResponseError404Body
79 28 : [:map {:swagger/title "DrawResponseError404Body"
80 : :swagger/description "Draw not found response"}
81 28 : [:message [:string {:example "Draw not found."}]]
82 20 : [:data {:optional true}
83 4 : nil?]])
84 :
85 :
86 4 : (def DrawDeleteResponseSuccess200Body
87 28 : [:map {:swagger/title "DrawDeleteResponseSuccess200Body"
88 : :swagger/description "Successful draw deletion response"}
89 28 : [:message [:string {:example "Draw deleted successfully."}]]])
90 :
91 :
92 : ;; Response Schemas
93 4 : (def DrawResponseSchema
94 : "Union of possible draw create/update responses."
95 8 : [:or
96 40 : [:map [:status [:= 200]] [:body DrawResponseSuccess200Body]]
97 40 : [:map [:status [:= 201]] [:body DrawResponseSuccess201Body]]
98 40 : [:map [:status [:= 400]] [:body DrawResponseError400Body]]
99 40 : [:map [:status [:= 404]] [:body DrawResponseError404Body]]])
100 :
101 :
102 4 : (def DrawListResponseSchema
103 : "Response for listing draws by stage."
104 8 : [:or
105 40 : [:map [:status [:= 200]] [:body DrawListResponseSuccess200Body]]
106 40 : [:map [:status [:= 400]] [:body DrawResponseError400Body]]])
107 :
108 :
109 4 : (def DrawDeleteResponseSchema
110 : "Response for deleting a draw."
111 8 : [:or
112 40 : [:map [:status [:= 200]] [:body DrawDeleteResponseSuccess200Body]]
113 40 : [:map [:status [:= 404]] [:body DrawResponseError404Body]]])
|