Data-driven Swagger clients.
Alpha, subject to change.
(require '[vainglory.client :as v])
; load a swagger spec from anything that can turn into a reader: files, URLs, etc.
(def petstore (v/load-json "https://petstore.swagger.io/v2/swagger.json"))
(def petstore-client (v/client petstore))
; all available ops returned as a map from v/ops
(v/ops petstore-client)
; get a data description of an operation
(:findPetsByStatus (v/ops petstore-client))
; invoke an operation
(v/invoke petstore-client {:op :findPetsByStatus :request {:status ["available"]}})
; async invoke is also available
(require '[vainglory.async :as va])
(require '[manifold.deferred :as d])
; invoke returns a manifold deferred that will yield the result
(d/chain
(va/invoke petstore-client {:op :findPetsByStatus :request {:status ["sold"]}})
(fn [result] ...))
Only supports Swagger 2.0 at the moment, and won't tell the difference if you feed it something else.
Mad props: inspired by aws-api.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close