Line data Source code
1 4 : (ns schemas.api.media "Schemas for gallery image endpoints.")
2 :
3 :
4 4 : (def MediaFocusRequestSchema
5 : ;; The handler owns validation so every malformed JSON body retains status 422.
6 : ;; Swagger describes accepted client input independently of runtime validation.
7 24 : [:any {:swagger/title "MediaFocusRequestSchema"
8 36 : :swagger {:title "MediaFocusRequestSchema"
9 : :description "Focus point of an image; both coordinates null clear it"
10 : :type "object"
11 12 : :required ["x" "y"]
12 56 : :properties {:x {:type ["number" "null"]
13 : :minimum 0
14 : :maximum 1
15 : :description
16 : "Fraction of the image width that must stay visible"}
17 : :y
18 44 : {:type ["number" "null"]
19 : :minimum 0
20 : :maximum 1
21 : :description
22 : "Fraction of the image height that must stay visible"}}}}])
23 :
24 :
25 4 : (def MediaFocusPathParamsSchema
26 20 : [:map {:swagger/title "MediaFocusPathParamsSchema"}
27 24 : [:asset-id {:description "Image asset id"}
28 : :string]])
29 :
30 :
31 4 : (def MediaFocusMessageBody
32 20 : [:map {:swagger/title "MediaFocusMessageBody"}
33 12 : [:message :string]])
34 :
35 :
36 4 : (def MediaFocusSuccessBody
37 20 : [:map {:swagger/title "MediaFocusSuccessBody"}
38 68 : [:data [:map [:id :string] [:focus-x [:maybe :double]] [:focus-y [:maybe :double]]]]])
39 :
40 :
41 4 : (def MediaFocusResponseSchema
42 8 : [:or
43 40 : [:map [:status [:= 200]] [:body MediaFocusSuccessBody]]
44 40 : [:map [:status [:= 403]] [:body MediaFocusMessageBody]]
45 40 : [:map [:status [:= 404]] [:body MediaFocusMessageBody]]
46 40 : [:map [:status [:= 422]] [:body MediaFocusMessageBody]]])
|