-
Notifications
You must be signed in to change notification settings - Fork 84
/
swagger2_schema.clj
38 lines (32 loc) · 991 Bytes
/
swagger2_schema.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
(ns ring.swagger.swagger2-schema
"Schemas that Ring-Swagger expects from it's clients"
(:require [schema.core :as s]))
(defn opt [x] (s/optional-key x))
(def X- (s/pred #(re-find #"x-" (name %)) ":x-.*"))
; https://groups.google.com/forum/#!topic/prismatic-plumbing/TVkIAJVEmpg
(s/defschema Responses s/Any)
(s/defschema Info
{X- s/Any
:title s/Str
(opt :version) s/Str
(opt :description) s/Str
(opt :termsOfService) s/Str
(opt :contact) {(opt :name) s/Str
(opt :url) s/Str
(opt :email) s/Str}
(opt :license) {:name s/Str
(opt :url) s/Str}})
(s/defschema Parameters
{(opt :body) s/Any
(opt :query) s/Any
(opt :path) s/Any
(opt :header) s/Any
(opt :formData) s/Any})
(s/defschema Operation
{(opt :parameters) Parameters
(opt :responses) Responses
s/Keyword s/Any})
(s/defschema Swagger
{(opt :info) Info
(opt :paths) {s/Str {s/Keyword (s/maybe Operation)}}
s/Keyword s/Any})