This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-09
Channels
- # aws (4)
- # bangalore-clj (1)
- # beginners (94)
- # boot (19)
- # cider (42)
- # cljs-dev (21)
- # cljsrn (4)
- # clojure (142)
- # clojure-austin (10)
- # clojure-greece (25)
- # clojure-italy (14)
- # clojure-russia (14)
- # clojure-serbia (13)
- # clojure-sg (6)
- # clojure-spec (74)
- # clojure-uk (69)
- # clojurescript (236)
- # consulting (1)
- # cursive (26)
- # data-science (6)
- # datascript (2)
- # datomic (31)
- # editors (5)
- # emacs (24)
- # funcool (5)
- # hoplon (8)
- # jobs-rus (1)
- # luminus (12)
- # lumo (17)
- # off-topic (90)
- # om (45)
- # onyx (5)
- # pedestal (2)
- # powderkeg (12)
- # protorepl (2)
- # re-frame (30)
- # remote-jobs (2)
- # ring-swagger (17)
- # rum (46)
- # slack-help (1)
- # test-check (2)
- # yada (62)
@mtkp you need to app the value of api
(or the defoned var with defapi
) into a ring-adapter (like http-kit) and start it. Here's an example: http://www.http-kit.org/server.html
I think there should be a minimalistic reloaded repl -enabled template for c-api. Maybe with Mount to keep it newbie-friendly... or an example project at least.
hey, new to compojure-api and swagger but trying to get it set up for my app. got it working yesterday (on 1.1.10) but now trying to add some token-based auth and not really sure what i'm doing. i've added :data {:securityDefinitions {:api_key {:type "apiKey" :name "token" :in "header"}}
to my swagger map but not seeing any differences when i open up my swagger page. is there supposed to be a ui element added for me to add my api token to my headers somewhere? am i supposed to do something else?
tried doing it through :header-params
which works but it doesn't look like i can provide it for an entire context, only individual endpoints, and i don't want to add that boilerplate to every endpoint that requires auth
to be clear: my auth works, i just want a way to still test my authenticated routes through swagger
Hey, I am using compojure-api for the data-driven resource style endpoints. However I can’t seem to figure out how to mark a query-param as optional. I have tried using s/maybe
but that doesn’t seem to work. Any ideas?
(def handler
(resource
{:summary "increments query-param x, defaulting to 1"
:parameters {:query-params {(s/optional-key :x) Long}}
:responses {200 {:schema Long}}
:handler (fn [request]
(ok (-> request :query-params :x (or 0) inc)))}))
(handler {:request-method :get, :query-params {:x "41"}})
; {:status 200, :headers {}, :body 42, :compojure.api.meta/serializable? true}
(handler {:request-method :get, :query-params {}})
; {:status 200, :headers {}, :body 1, :compojure.api.meta/serializable? true}
ah I see, my bad I was trying to make the value optional but they key to the solution was the key 😛
@csapp there should be a top-bar authentication link, which open a modal where you can enter the api-key
also, you can mount authentication middleware at any level of your routing tree via the :middleware
option. either to api
(effects all routes), to context
(bunch of routes) or to endpoint (just that one. You don’t have to add the :header-param
, the top-level swagger :securityDefinitions
should effect all. e.g. when it’s given via the ui, it’s passed to all requests.
the actual enforcement of the api-key could be a middleware. Sadly, currently the basic-auth, token-auth & others are separate ring-libs, so you need to collect them together.
If someone would have extra time, would like to see them prepackaged with compojure-api as they are commonly used.
there is a good example by @yogthos here: https://github.com/yogthos/memory-hole
here’s the issue: https://github.com/metosin/compojure-api/issues/122