|
2 | 2 | (:require [clojure.test :refer :all] |
3 | 3 | [ring.swagger.openapi3 :refer :all] |
4 | 4 | [schema.core :as s] |
5 | | - [ring.swagger.extension :as extension] |
6 | 5 | [ring.swagger.openapi3-validator :as validator] |
7 | 6 | [midje.sweet :refer :all]) |
8 | | - (:import (java.time Instant) |
| 7 | + (:import |
9 | 8 | [java.util Date UUID] |
10 | 9 | [java.util.regex Pattern] |
11 | 10 | [org.joda.time DateTime LocalDate LocalTime])) |
|
40 | 39 | (if-let [output-errors (validate-swagger-json swagger options)] |
41 | 40 | {:output-errors output-errors})))) |
42 | 41 |
|
43 | | -(def a-complete-swagger |
44 | | - {:info {:version "version" |
45 | | - :title "title" |
46 | | - :description "description" |
47 | | - :termsOfService "jeah" |
48 | | - :contact {:name "name" |
49 | | - :url "http://someurl.com" |
50 | | - |
51 | | - :license {:name "name" |
52 | | - :url "http://someurl.com"}} |
53 | | - :servers [{:url "somehost:8080"}] |
54 | | - :externalDocs {:url "http://someurl.com" |
55 | | - :description "more info"} |
56 | | - :tags [{:name "pet", |
57 | | - :description "Everything about your Pets", |
58 | | - :externalDocs {:description "Find out more", :url "http://swagger.io"}} |
59 | | - {:name "store", |
60 | | - :description "Access to Petstore orders"} |
61 | | - {:name "user", |
62 | | - :description "Operations about user", |
63 | | - :externalDocs {:description "Find out more about our store", :url "http://swagger.io"}}] |
64 | | - :paths {"/api/:id" {:get {:tags ["pet"] |
65 | | - :summary "summary" |
66 | | - :description "description" |
67 | | - :operationId "operationId" |
68 | | - :parameters {:query (merge Anything {:x Long :y Long}) |
69 | | - :path {:id String} |
70 | | - :header Anything} |
71 | | - :responses {"200" {:description "ok" |
72 | | - :content {"application/json" {:schema Parrot}}} |
73 | | - "400" {:description "not found" |
74 | | - :content {"application/json" {:schema nil}}}}}}}}) |
75 | | - |
76 | 42 | (def a-complete-swagger-2 |
77 | 43 | {:info {:version "version" |
78 | 44 | :title "title" |
|
103 | 69 | :parameters {:query (merge Anything {:x Long :y Long}) |
104 | 70 | :path {:id String} |
105 | 71 | :header Anything} |
106 | | - :responses {"200" {:description "ok" |
107 | | - :content {"application/json" {:schema nil}}} |
108 | | - "400" {:description "not found" |
109 | | - :content {"application/json" {:schema NotFound}}}} |
110 | | - #_"default" #_{:description "error" |
111 | | - :content {"application/json" {:schema {:code Long}}}}}} |
| 72 | + :responses {"200" {:description "ok" |
| 73 | + :content {"application/json" {:schema nil}}} |
| 74 | + "400" {:description "not found" |
| 75 | + :content {"application/json" {:schema NotFound}}} |
| 76 | + "default" {:description "error" |
| 77 | + :content {"application/json" {:schema {:code Long}}}}}}} |
112 | 78 | "/api/parrots" {:get {:responses {"200" {:description "ok" |
113 | 79 | :content {"application/json" {:schema Parrot}}}}}} |
114 | 80 | "/api/all-types" {:get {:requestBody {:content {"application/json" {:a Boolean |
|
130 | 96 | :w #"a[6-9]"}}}} |
131 | 97 | :responses {"200" {:description "file" |
132 | 98 | :content {"application/json" {:schema Parrot}}}}}} |
133 | | - "/api/pets" {:get {:parameters {:query (merge Anything {:x Long :y Long}) |
134 | | - :path Nothing |
135 | | - :header Anything} |
| 99 | + "/api/pets" {:get {:parameters {:query (merge Anything {:x Long :y Long})} |
136 | 100 | :requestBody {:content {"application/json" Pet}} |
137 | | - :responses {"200" {:description "ok" |
138 | | - :content {"application/json" {:schema {:sum Long}}}} |
139 | | - #_:default #_{:description "error" |
140 | | - :content {"application/json" {:schema Parrot}}}}} |
| 101 | + :responses {"200" {:description "ok" |
| 102 | + :content {"application/json" {:schema {:sum Long}}}} |
| 103 | + "default" {:description "error" |
| 104 | + :content {"application/json" {:schema Parrot}}}}} |
141 | 105 | :post {:parameters {:query (merge Anything {:x Long :y Long})} |
142 | 106 | :requestBody {:content {"application/json" [Pet]}} |
143 | | - :responses {"200" {:content {"application/xml" {:schema {:sum Long}}}} |
144 | | - #_:default #_{:content {"application/json" {:schema {:code Long}}} |
145 | | - :headers {:location String}}}} |
| 107 | + :responses {"200" {:content {"application/xml" {:schema {:sum Long}}}} |
| 108 | + "default" {:content {"application/json" {:schema {:code Long}}} |
| 109 | + :headers {:location String}}}} |
146 | 110 | :put {:parameters {:query {:x (s/maybe String)}} |
147 | 111 | :requestBody {:content {"application/json" [(s/maybe Pet)]}} |
148 | 112 | :responses {"200" {:description "ok" |
149 | 113 | :content {"application/json" {:schema {:sum (s/maybe Long)}}}}}}} |
150 | | - "/api/turtle" {:get {:parameters {:query (merge Anything {:x Long :y Long}) |
151 | | - :path Nothing |
152 | | - :header Anything} |
| 114 | + "/api/turtle" {:get {:parameters {:query (merge Anything {:x Long :y Long})} |
153 | 115 | :requestBody {:content {"application/json" Turtle}} |
154 | | - :responses {"200" {:description "ok" |
155 | | - :content {"application/json" {:schema {:sum Long}}}} |
156 | | - #_:default #_{:description "error" |
157 | | - :content {"application/json" {:schema {:code Long}}}}}} |
| 116 | + :responses {"200" {:description "ok" |
| 117 | + :content {"application/json" {:schema {:sum Long}}}} |
| 118 | + "default" {:description "error" |
| 119 | + :content {"application/json" {:schema {:code Long}}}}}} |
158 | 120 | :post {:parameters {:query (merge Anything {:x Long :y Long})} |
159 | 121 | :requestBody {:content {"application/json" [Turtle]}} |
160 | | - :responses {"200" {:content {"application/json" {:schema {:sum Long}}}} |
161 | | - #_:default #_{:content {"application/json" {:schema {:code Long}}} |
162 | | - :headers {:location String}}}} |
| 122 | + :responses {"200" {:content {"application/json" {:schema {:sum Long}}}} |
| 123 | + "default" {:content {"application/json" {:schema {:code Long}}} |
| 124 | + :headers (merge Anything {:location String})}}} |
163 | 125 | :put {:parameters {:query {:x (s/maybe String)}} |
164 | 126 | :requestBody {:content {"application/json" [(s/maybe Turtle)]}} |
165 | 127 | :responses {"200" {:description "ok" |
|
0 commit comments