/
navigation.clj
65 lines (53 loc) · 2.44 KB
/
navigation.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
(ns common-swagger-api.schema.data.navigation
(:use [clojure-commons.error-codes]
[common-swagger-api.schema :only [describe CommonResponses ErrorResponseUnchecked]]
[common-swagger-api.schema.data :as data-schema]
[common-swagger-api.schema.stats :as stats-schema])
(:require [schema.core :as s]))
(def NavigationRootSummary "Root Listing")
(def NavigationRootDocs
"This endpoint provides a shortcut for the client to list the top-level directories
(e.g. the user's home directory, trash, and shared directories).")
(def NavigationSummary "Directory List (Non-Recursive)")
(def NavigationDocs
"Only lists subdirectories of the directory path passed into it.")
(s/defschema UserBasePaths
{:user_home_path (describe String "The absolute path to the user's home folder")
:user_trash_path (describe String "The absolute path to the user's trash folder")
:base_trash_path (describe String "The absolute path to the base trash folder")})
(s/defschema RootListing
(dissoc stats-schema/DataStatInfo :type))
(s/defschema NavigationRootResponse
{:roots [RootListing]
:base-paths UserBasePaths})
(s/defschema FolderListing
(-> stats-schema/DataStatInfo
(dissoc :type)
(assoc (s/optional-key :folders)
(describe [(s/recursive #'FolderListing)] "Subdirectories of this directory"))))
(s/defschema NavigationResponse
{:folder FolderListing})
(def NavigationRootErrorCodeResponses
(conj data-schema/CommonErrorCodeResponses
ERR_DOES_NOT_EXIST
ERR_NOT_READABLE
ERR_NOT_A_USER))
(s/defschema NavigationRootErrorResponses
(merge ErrorResponseUnchecked
{:error_code (apply s/enum NavigationRootErrorCodeResponses)}))
(s/defschema NavigationErrorResponses
(merge ErrorResponseUnchecked
{:error_code (apply s/enum (conj NavigationRootErrorCodeResponses
ERR_NOT_A_FOLDER))}))
(s/defschema NavigationRootResponses
(merge CommonResponses
{200 {:schema NavigationRootResponse
:description "The Root Listing."}
500 {:schema NavigationRootErrorResponses
:description data-schema/CommonErrorCodeDocs}}))
(s/defschema NavigationResponses
(merge CommonResponses
{200 {:schema NavigationResponse
:description "The Folder Listing."}
500 {:schema NavigationErrorResponses
:description data-schema/CommonErrorCodeDocs}}))