Fork me on GitHub

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.


@ikitommi any road map for upgrading to swagger 3.x?


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 resources). Also, plumbing might need a PR.


@romain yes, as soon as have time. Contributions would be welcome.


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.


@ikitommi do you have any doc or guide to help getting in?


@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.


e.g. reuse the ring.swagger.json-schema for both.


I see, thanks a lot @ikitommi and @romain 🙂


the spec-swagger/openapi stuff lives in, we can develop it parallel to the schema+openapi3.


np. Would be awesome if you could cook up the 3 support for Schema.


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


The specifications for 3.0 are still in draft but it should enough to start


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


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.


Let me check


Looks like yes. Have this: :format {:formats [:json-kw :edn :transit-json]} in the api call.


That should work, then


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.


Oh, okay, that's bad 😞


Just for information, the issue was I added a responses to a route without actually knowing how and it was bad. Removing it fixed the issue. It looked like:

:responses {400 [String]}


Ah well. There should be some kind of validation instead of things just mysteriously breaking.