/
exists.clj
50 lines (41 loc) · 1.81 KB
/
exists.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
(ns common-swagger-api.schema.data.exists
(:use [clojure-commons.error-codes]
[common-swagger-api.schema
:only [describe
doc-only
CommonResponses
ErrorResponseUnchecked]])
(:require [common-swagger-api.schema.data :as data-schema]
[schema.core :as s]))
(def ExistenceSummary "File and Folder Existence")
(def ExistenceDocs
"This endpoint allows the caller to check for the existence of a set of files and folders.")
(s/defschema ExistenceRequest
(describe data-schema/Paths "The paths to check for existence."))
(s/defschema PathExistenceMap
{(describe s/Keyword "The iRODS data item's path")
(describe Boolean "Whether this path from the request exists")})
(s/defschema ExistenceInfo
{:paths
(describe PathExistenceMap "Paths existence mapping")})
;; Used only for display as documentation in Swagger UI
(s/defschema ExistenceResponsePathsMap
{:/path/from/request/to/a/file/or/folder
(describe Boolean "Whether this path from the request exists")})
;; Used only for display as documentation in Swagger UI
(s/defschema ExistenceResponse
{:paths
(describe ExistenceResponsePathsMap "A map of paths from the request to their existence info")})
(def ExistenceErrorCodeResponses
(conj data-schema/CommonErrorCodeResponses
ERR_NOT_A_USER
ERR_TOO_MANY_RESULTS))
(s/defschema ExistenceErrorResponses
(merge ErrorResponseUnchecked
{:error_code (apply s/enum ExistenceErrorCodeResponses)}))
(s/defschema ExistenceResponses
(merge CommonResponses
{200 {:schema (doc-only ExistenceInfo ExistenceResponse)
:description "A map of paths from the request to their existence info"}
500 {:schema ExistenceErrorResponses
:description data-schema/CommonErrorCodeDocs}}))