martian

The HTTP abstraction library for Clojure/script, supporting OpenAPI, Swagger, Schema, re-frame and more

MIT License

Downloads
544.2K
Stars
514
Committers
29

Bot releases are visible (Hide)

martian - One for the re-framers

Published by oliyh about 7 years ago

This release improves the martian story in Clojurescript, with improvements to the cljs-http library and a new library called martian-re-frame which provides bindings to use martian idiomatically with re-frame.

The API for martian-test was also improved to allow easier stubbing of responses.

The following issues were addressed:

  • cljs-http Leave interceptors are run inside a go block, so they no longer need to be aware of core.async #41
  • re-frame bootstrap signature now allows you to pass in your own interceptors and options #36
  • re-frame Added a subscription for the martian instance #37
  • Martian re-frame should call on-fail if inputs can't be coerced rather than throw exception #38
  • Body params don't work for s/Any #44
  • Martian test should have helpers to respond for individual operation ids #45
martian - Camel, Snake, Kebab

Published by oliyh about 7 years ago

This release further improves martian's idiomatic Clojure credentials by inferring the mappings between the field names used by the API and the idiomatic Clojure key - for example, if the API requires a key FooBar you can provide :foo-bar to martian. This is covered in more detail in #34.

The following issues were addressed:

  • Optionally destructure body params #31
  • Maybe schemas prevent body destructuring #35
  • Query and body param names cannot be kebab cased #32
  • Map idiomatic kebab keys for params for query, headers, body, form #34
martian - Per-route interceptors

Published by oliyh almost 8 years ago

The major feature introduced in this release is the ability to provide interceptors for individual handlers. This allows you to handle special cases much more elegantly.

They can be defined either as part of the bootstrap data:

(martian/bootstrap "https://api.org"
                   [{:route-name :load-pet
                     :path-parts ["/pets/" :id]
                     :method :get
                     :path-schema {:id s/Int}
                     :interceptors [{:id ::override-load-pet-method
                                     :enter #(assoc-in % [:request :method] :xget)}]}])

Or by using the helper to modify an existing martian record:

(-> (martian/bootstrap-swagger "https://api.org" swagger-definition)
    (martian/update-handler :load-pet assoc :interceptors [{:id ::override-load-pet-method
                                                            :enter #(assoc-in % [:request :method] :xget)}]))

Other changes include:

  • Better support for json array bodies via #26 and #29 - nb this is a breaking change to the parameters for bodies, see #5
  • The body can be provided verbatim with :martian.core/body, see #30 (thanks @markdingram)
martian - Bugfix: produces/consumes mixup

Published by oliyh almost 8 years ago

Fixed a bug where consumes parameter was taken from the produces key resulting in incorrect serialisation on bodies where consumes was different to produces.

https://github.com/oliyh/martian/commit/d8194084adf23cc4d2e323b4e34b85beb04335ea

martian - Initial release

Published by oliyh almost 8 years ago

Please view the readme for details.

martian - Generative testing & non-Swagger support

Published by oliyh almost 8 years ago

This release focussed mainly on improving the martian API for more practical use and adding the ability to perform generative testing.

  • Added response generators for use with test.check and documented usage in the martian-test readme
  • Added a bootstrap function which accepts data structures describing APIs in a Swagger-like way without requiring Swagger at all
  • All provided interceptors now behave better with other interceptors that may want to collaborate or override some parameters
  • Added support for Boolean type
  • cljs-http bootstrap-swagger now works with relative urls as well as absolute
Package Rankings
Top 6.09% on Clojars.org
Badges
Extracted from project README
Clojars Project cljdoc badge Clojars Project cljdoc badge Clojars Project cljdoc badge Clojars Project cljdoc badge Clojars Project cljdoc badge Clojars Project cljdoc badge Clojars Project cljdoc badge Clojars Project cljdoc badge Clojars Project Clojars Project cljdoc badge Clojars Project cljdoc badge Circle CI
Related Projects