ring-swagger & compojure-api
bja 2017-11-08T15:52:28.000856Z

each of my services publishes their schemas under a certain endpoint convention and my clients can consume those (since the schemas often are more complex than what can be represented by swagger)


right we define all our schemas in a shared utility library


i’m more talking about coercing the json response from one of our services into clojure datastructures using a given schema


right now we manually call ring.swagger.schema/coerce! on the json response and pass it the relevant schema


just seemed like something someone might have built a library for

ikitommi 2017-11-08T17:14:07.000634Z

Interesting. What would the library do?

ikitommi 2017-11-08T17:19:28.000805Z

It would be cool if schemas & specs would have symmetric encode & decode, so they could be used over the wire. Spec gets close with this.

ikitommi 2017-11-08T17:20:29.000173Z

Something related: https://github.com/metosin/compojure-api/issues/148 & https://github.com/oliyh/martian


well i’m imagining a wrapper around clj-http that could take a :responses map like you define in your api and automatically coerce the json for you


nice, martian looks close

ikitommi 2017-11-08T17:23:26.000064Z

There is also https://github.com/swagger-api/swagger-codegen


yeah the problem with using swagger directly is you lose the schema part


the main reason we use coerce! is to convert date/money strings back into joda time/money objects


which swagger can’t represent

ikitommi 2017-11-08T17:28:59.000092Z

If the client can access the some shared schema/spec namespaces, it would be possible to create a martian-style client for schema/spec.


yeah all schema is shared in a utility library


definitely gonna look into martian


yeah i think the main issue with martian is it doesn’t support async yet