ring-swagger & compojure-api
florinbraghis 2018-12-06T16:43:56.062700Z

A couple of ideas that could help: 1. There could be an optional callback that users can supply in the options, which receives this Swagger map that they can modify freely, called just before ensure-body-and-response-schema-names 2. Instead of BodyXXX and ResponseXXX, adopt a more predictable naming scheme for unnamed schemas. For example, MethodPathBody for body params inline schemas (eg. GetApiPlusBody, GetDocuments{id}Body) and MethodPathResponseCode for responses (eg. GetApiPlusResponse200 GetDocuments{id}Response401). 3. Both or something even better? What do you think about these solutions ?

ikitommi 2018-12-06T18:27:28.062900Z

@florinbraghis I think providing the options is a good idea, also the callback for the schema naming. Are there any other (non-clojure) naming conventions for swagger out there? Would you like to do a PR for spec-tools?

ikitommi 2018-12-06T18:29:21.063100Z

oh, you are using Schema. We started to port Schema->Swagger from ring-swagger to schema-tools. Not on par yet, but at some point will make c-api use that instead.


Hello, I’m using compojure-api version “2.0.0-alpha28”, trying to set up an async handler.

(context "/test" []
      :tags ["Testing"]
      (GET "/" []
        :summary "testing"
          (async/<! (async/timeout 500))
          (ok {:message "Hello"}))))
When i try to hit the endpoint, I get:
ERROR compojure.api.exception: No implementation of method: :render of protocol: #'compojure.response/Renderable found for class: clojure.core.async.impl.channels.ManyToManyChannel
I’ve noticed that in https://github.com/metosin/compojure-api/tree/master/examples/async the project.clj contains
:ring {:handler example.handler/app
         :async? true}
but from what I understand, that’s only relevant when running with lein, which I’m not doing. Any thoughts?

ikitommi 2018-12-06T20:57:24.067200Z

@jon324 hi. the async requires the server to be run in ring-async mode: the server should call the application with 3 arguments, described in here: https://www.booleanknot.com/blog/2016/07/15/asynchronous-ring.html

ikitommi 2018-12-06T20:59:42.069300Z

Jetty support ring-async oob, with Aleph, Immutant or http-kit, you need to write 1+ lines of boilerplate to do this.


Are there any resources for the boilerplate for aleph?


I’m trying to see if I can do something similar with Jetty by following this blog post: https://www.lucagrulla.com/posts/server-sent-events-with-ring-and-compojure/ On this line (fn [req res raise] I get

ERROR compojure.api.exception: Wrong number of args (1) passed to: services/fn--41918/fn--41919
clojure.lang.ArityException: Wrong number of args (1) passed to: services/fn--41918/fn--41919
        at clojure.lang.AFn.throwArity(AFn.java:429)
        at clojure.lang.AFn.invoke(AFn.java:32)
        at compojure.response$eval18314$fn__18315.invoke(response.clj:47)
        at compojure.response$eval18236$fn__18237$G__18227__18244.invoke(response.clj:7)
        at compojure.core$wrap_response$fn__20191.invoke(core.clj:158)
        at compojure.core$wrap_route_middleware$fn__20175.invoke(core.clj:128)
        at compojure.core$wrap_route_info$fn__20180.invoke(core.clj:137)
        at compojure.core$wrap_route_matches$fn__20184.invoke(core.clj:146)
        at compojure.api.routes.Route.invoke(routes.clj:90)
        at compojure.core$routing$fn__20199.invoke(core.clj:185)


Any ideas why I’m having trouble with the arity 3 call?