oliyh / martian

The HTTP abstraction library for Clojure/script, supporting OpenAPI, Swagger, Schema, re-frame and more
MIT License
526 stars 45 forks source link

Is response validation supported? #69

Closed omartell closed 3 years ago

omartell commented 4 years ago

Hey Oliy,

I was trying to figure out how to do response validation when doing the manual endpoint definition, but couldn't find it in the documentation. I had a look around the code and all I could see was a key called :response-schemas used by the explore call, but that didn't seem to trigger any validation. Is this supported? or do I need a different incantation?

Cheers, Oliver

oliyh commented 4 years ago

Hi Oliver,

No, there's nothing that does response validation at the moment. It should be fairly straightforward to write an interceptor to do so - I think you would want to use schema's cond-pre to choose the right schema based on the status code of the response. If you write this I would happily accept a PR or gist.

The only use of the response schemas at the moment is for documentation in explore as you've already seen and for generating responses in martian-test.

oliyh commented 3 years ago

Hi @omartell

This is added in 0.1.15, enjoy :)

Cheers

omartell commented 3 years ago

Nice one @oliyh.