This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-12
Channels
- # bangalore-clj (1)
- # beginners (28)
- # boot (33)
- # chestnut (3)
- # cider (35)
- # cljs-dev (64)
- # cljsrn (16)
- # clojure (95)
- # clojure-android (6)
- # clojure-austin (1)
- # clojure-italy (5)
- # clojure-korea (1)
- # clojure-russia (55)
- # clojure-sg (1)
- # clojure-spec (25)
- # clojure-uk (57)
- # clojurescript (120)
- # code-reviews (7)
- # community-development (2)
- # core-async (3)
- # cursive (6)
- # data-science (3)
- # datascript (10)
- # datomic (12)
- # devcards (1)
- # emacs (9)
- # gsoc (7)
- # hoplon (18)
- # lumo (2)
- # off-topic (10)
- # om (24)
- # onyx (17)
- # pedestal (46)
- # powderkeg (1)
- # protorepl (7)
- # re-frame (31)
- # ring-swagger (34)
- # spacemacs (10)
- # specter (9)
- # sql (39)
- # unrepl (9)
- # untangled (3)
- # utah-clojurians (1)
Hi all! I am not very experienced with Clojure, but I am wondering if it is possible to use compojure-api using clojure.spec instead of Schema? To my understanding this means the swagger docs will not be generated, but is it possible to use to make an API anyway?
@maja yes and no. Compojure-api builds on compojure.api.routes/Route
-records. You can create a custom`Route` that validates with spec and mount it to the routing tree just like GET
, resource
& others.
Idea is to make tje validation lib pluggable, schema, spec or any other. We try to get this right, so need some thinking before finalizing (have a almost working branch with resource
s). Also, plumbing might need a PR.
we are doing now the spec->swagger2, openapi3 would be easy after that. Merge with ring-swagger after that. My guess is that all is done before the midsummer party.
@romain ring-swagger source :) It could have a openapi3
ns, just like there is swagger2
JSON Schema support is better in 3, the version could be passed into the tranformation functions.
the spec-swagger/openapi stuff lives in https://github.com/metosin/spec-swagger, we can develop it parallel to the schema+openapi3.
Btw, new (async) ring 1.6.0 versions of all our ring libs are now out (ring-http-response, ring-swagger, muuntaja, compojure-api)
I'm still new to ring, swagger and Clojure contributions, I will try to give a look the project doesn't seem to be complicated and heavy
Hi. I’ve updated my app to use compojure-api from 1.0.1 to 1.1.10 and the swagger UI stopped working. I’ve changed the calls to swagger-ui
and swagger-docs
to swagger-routes
but swagger.json is empty. I saw this note in the CHANGELOG for 1.1.0 and think it is relevant but I’m not sure what I need to do.
api-level swagger-options default to {:ui nil, :spec nil}. Setting up just the spec or ui, doesn't automatically setup the other (like previously)
Any suggestions?Hmmh, if you're explicitly calling swagger-routes
, that shouldn't matter, because that should setup both.
Oh, yes. Been reading code. Still not sure why swagger.json
is empty even though it worked fine before the upgrade. 😞
It could be because for some reason the ring-swagger swagger-data middleware is not included
hmm https://github.com/metosin/compojure-api/blob/1.1.10/src/compojure/api/middleware.clj#L237
Do you have the ring-middleware-format middleware enabled? I.e. non-nil :format
. Because that looks like that the swagger data middleware is enable only if the format middleware is enabled.
Looks like yes. Have this: :format {:formats [:json-kw :edn :transit-json]}
in the api
call.
How empty is your swagger.json
? Like, no-body-at-all, or 404, or like some JSON but without paths and definitions?
204 no content empty. I went back to the old calls to swagger-docs and swagger-routes and now I get
500 : {"error":{"type":"unknown-error","message":"Key must be integer"}}
I'd probably call get-routes
on the result of your api
call to check that swagger.json
is mounted where you think it should be mounted, or anywhere at all. And I assume you get a stacktrace for that error in console, or something?
That is another issue, my logging is gone too. I’m going to wind back a bunch of upgraded packages, then start adding them back and see where the issue reoccurs.