ring-swagger

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)

2017-11-08T17:09:37.000528Z

right we define all our schemas in a shared utility library

2017-11-08T17:10:24.000499Z

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

2017-11-08T17:11:54.000231Z

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

2017-11-08T17:12:05.000184Z

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

2017-11-08T17:20:44.000501Z

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

2017-11-08T17:22:19.000092Z

nice, martian looks close

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

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

2017-11-08T17:24:07.000318Z

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

2017-11-08T17:24:31.000686Z

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

2017-11-08T17:24:50.000240Z

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.

2017-11-08T17:29:33.000388Z

yeah all schema is shared in a utility library

2017-11-08T17:29:39.000330Z

definitely gonna look into martian

2017-11-08T18:12:43.000640Z

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