|
26 | 26 | - [pedastal-swagger](https://github.com/frankiesardo/pedestal-swagger) for Pedastal |
27 | 27 | - [rook](https://github.com/AvisoNovate/rook) |
28 | 28 |
|
29 | | -Route definitions as expected as a clojure Map defined by the [Schema](https://github.com/metosin/ring-swagger/blob/master/src/ring/swagger/swagger2_schema.clj). |
30 | | -The Schema is open as ring-swagger tries not to be on your way - one can always pass any extra data in the Swagger Spec format. The generated specs can be validated against |
31 | | -the [Swagger Schema](https://raw.githubusercontent.com/reverb/swagger-spec/master/schemas/v2.0/schema.json) via tools like |
32 | | -[scjsv](https://github.com/metosin/scjsv). |
| 29 | +Route definitions as expected as a clojure Map defined by the [Schema](https://github.com/metosin/ring-swagger/blob/master/src/ring/swagger/swagger2_schema.clj). The Schema is open as ring-swagger tries not to be on your way - one can always pass any extra data in the Swagger Spec format. |
33 | 30 |
|
34 | 31 | ### Simplest possible example |
35 | 32 |
|
@@ -58,23 +55,38 @@ the [Swagger Schema](https://raw.githubusercontent.com/reverb/swagger-spec/maste |
58 | 55 | :address {:street s/Str |
59 | 56 | :city (s/enum :tre :hki)}}) |
60 | 57 |
|
61 | | -(rs/swagger-json {:info {:title "Cool API" |
62 | | - :contact {:email "my@example.com"}} |
63 | | - :tags [{:name "user" |
64 | | - :description "User stuff"}] |
65 | | - :paths {"/api/ping" {:get nil} |
66 | | - "/user/:id" {:post {:summary "User Api" |
67 | | - :description "User Api description" |
68 | | - :tags ["user"] |
69 | | - :parameters {:path {:id s/Str} |
70 | | - :body User} |
71 | | - :responses {200 {:schema User |
72 | | - :description "Found it!"} |
73 | | - 404 {:description "Ohnoes."}}}}}}) |
| 58 | +(s/with-fn-validation |
| 59 | + (rs/swagger-json |
| 60 | + {:info {:version "1.0.0" |
| 61 | + :title "Sausages" |
| 62 | + :description "Sausage description" |
| 63 | + :termsOfService "http://helloreverb.com/terms/" |
| 64 | + :contact {:name "My API Team" |
| 65 | + :email "foo@example.com" |
| 66 | + :url "http://www.metosin.fi"} |
| 67 | + :license {:name "Eclipse Public License" |
| 68 | + :url "http://www.eclipse.org/legal/epl-v10.html"}} |
| 69 | + :tags [{:name "user" |
| 70 | + :description "User stuff"}] |
| 71 | + :paths {"/api/ping" {:get nil} |
| 72 | + "/user/:id" {:post {:summary "User Api" |
| 73 | + :description "User Api description" |
| 74 | + :tags ["user"] |
| 75 | + :parameters {:path {:id s/Str} |
| 76 | + :body User} |
| 77 | + :responses {200 {:schema User |
| 78 | + :description "Found it!"} |
| 79 | + 404 {:description "Ohnoes."}}}}}})) |
74 | 80 | ; {:swagger "2.0" |
75 | | -; :info {:title "Cool API" |
76 | | -; :version "0.0.1" |
77 | | -; :contact {:email "my@example.com"}} |
| 81 | +; :info {:version "1.0.0" |
| 82 | +; :title "Sausages" |
| 83 | +; :description "Sausage description" |
| 84 | +; :termsOfService "http://helloreverb.com/terms/" |
| 85 | +; :contact {:email "foo@example.com" |
| 86 | +; :name "My API Team" |
| 87 | +; :url "http://www.metosin.fi"} |
| 88 | +; :license {:name "Eclipse Public License" |
| 89 | +; :url "http://www.eclipse.org/legal/epl-v10.html"}} |
78 | 90 | ; :produces ["application/json"] |
79 | 91 | ; :consumes ["application/json"] |
80 | 92 | ; :paths {"/api/ping" {:get {:responses {:default {:description ""}}}} |
@@ -105,6 +117,8 @@ the [Swagger Schema](https://raw.githubusercontent.com/reverb/swagger-spec/maste |
105 | 117 |
|
106 | 118 | ### validating the results |
107 | 119 |
|
| 120 | +The generated full spec can be validated against the [Swagger JSON Schema](https://raw.githubusercontent.com/reverb/swagger-spec/master/schemas/v2.0/schema.json) via tools like [scjsv](https://github.com/metosin/scjsv). |
| 121 | + |
108 | 122 | ```clojure |
109 | 123 | (require '[scjsv.core :as scjsv]) |
110 | 124 |
|
|
0 commit comments