Fork me on GitHub
#ring-swagger
<
2016-07-21
>
ikitommi09:07:10

@quimrstorres: hi. there is a way, overriding the :coercion for api, context or endpoint. Nowhere near computer, but here are some pointers: https://github.com/metosin/compojure-api/wiki/Building-Documented-Apis#coercion, https://github.com/metosin/compojure-api/blob/master/test/compojure/api/coercion_test.clj#L139. I think there should be an easier way, or at least better examples but hope this helps. I would start with creating an string->vector schema matcher (see the plumatic schema guides), test it separately and only after then plug it into c-api.

ikitommi09:07:53

Schema matchers don't compose easily, to get your own matcher + default matchers, you have to use something like (schema-tools.coerce/or-matcher my-string->vector-matcher ring.swagger.coerce/query-schema-coercion-matcher).

jqmtor09:07:44

Hi @ikitommi . I’ve been through that pages but I was wondering because I also thought there might be an easier way. Thanks for the great help. If you think I could contribute with the examples or even in submitting any kind of improvement, let me know. 🙂

ikitommi10:07:11

@quimrstorres: contributions welcome! I think a great start would be to cut&paste the coersion-part of the old README into a separate wiki page + possible more examples on real life cases (Wiki is open for all to modify).

ikitommi10:07:33

if you think there is an easier way to customize coercion, please share :) Discussed some time ago about :matchers, but couldn't make it work on paper good enough.

jqmtor13:07:05

I will definitely do the changes you suggested to the docs. When you refer to :matchers, you are suggesting to add an option on the api, context and route to customize the matchers used, right?

ikitommi17:07:42

that (`:matchers`) was one idea. Not implemented and not sure how useful it would be. All ears on a good way to handle the custom coercion in an easy way.