Moro again: is there a way to add custom matchers for Reitit Schema coercion like there is for ring swagger: https://github.com/metosin/ring-swagger#custom-coercions ? I found the current coercions in https://github.com/metosin/schema-tools/blob/master/src/schema_tools/coerce.cljc, but could not figure out a clean way to add more. More specifically, we’d like to corce date strings to OffsetDateTime instances.
@yka depends on which schema lib you are using. For Plumatic: https://github.com/metosin/reitit/blob/0.3.10/modules/reitit-schema/src/reitit/coercion/schema.cljc#L39
Yeah. We are using Prismatic schema. So is the idea to override the default-coercion-matcher
with an own implementation?
Yeah. IIRC it's a map of type => coercion fn, so you'd probably merge your coercers to the existing
Aha, Malli has maps. Schema-tools has these functions: https://github.com/metosin/schema-tools/blob/master/src/schema_tools/coerce.cljc#L284-L287
so you could merge your own impl by using some-fn with existing matcher and your own
Ok. In my case we’d need the matcher for json requests, so I guess I’d need to build on that json-coercion-matcher
and add my own implementation on top of that with some-fn
? I’ll try that approach. Thanks!
So I'm using Reitit and Ring, and I have an endpoint where I need to close a resource when the response has been fully sent (I'm returning an input-stream that's being read from a database, and I need to close the associated transaction). How can I do this?