Fork me on GitHub
#ring-swagger
<
2017-03-06
>
mll07:03:57

Does anyone know hot to make query parameters in compojure-api optional?

mll07:03:28

`(defapi app (GET "/hello" [] :query-params [name :- String] (ok {:message (str "Hello, " name)})))`

mll07:03:54

I'd like to make name optional

ikitommi07:03:58

Hi. Compojure-api uses the fnk-syntax (https://github.com/plumatic/plumbing/tree/master/src/plumbing/fnk), so: :query-params [{name :- String “default value”}]

mll08:03:51

That was exactly what I was looking for

singen09:03:46

I’ve been scratching my head over the securityDefinitions in compojure-api, parts of my API require “basic” and parts of it require “header” auth, but I can’t seem to get either to show up in Swagger UI

singen09:03:13

I tried out something like the above and nothing happens

juhoteperi10:03:15

Examples in that page look like just Swagger spec, so that should give some idea

juhoteperi10:03:17

:data should be written to spec as is, so you should be able to define :security using that

juhoteperi10:03:59

and for setting :security per route, you can use :swagger metadata handler

ikitommi10:03:00

e.g. add to your route :swagger {:security {:basicAuth []}} too.

ikitommi10:03:49

If someone has time, would be an awesome PR to integrate buddy into c-api for making the swagger+security mappings transparent.

ikitommi10:03:56

e.g. define => enforce & document. or an example project.

ikitommi10:03:01

all the hooks for this should be available: an mw that defines the auth via buddy + contributes to swagger-docs and an restructuring for the routes/endpoints to apply the rules.

ikitommi11:03:02

the last one could be a middleware too. so 2 new auth-middleware should do it.

singen11:03:08

Thanks, I’ll try this out, the docs are quite limited

ikitommi11:03:11

are you going tomorrow to your Tech Meetup? I am, 🍻 & pair-programming before that?

singen11:03:06

@ikitommi Are you asking me? Is Reaktor holding a tech-meetup? I am no longer working there, but I’d love to have beers and chat sometime

singen11:03:26

Also, I’d loooooove for someone to take a look at our Clojure code

ikitommi11:03:20

@singen oh, didn't know you're not. Going for a beer ~16 tomorrow anyways, meetup starts at 17. I can peek at your code tomorrow or later when in town. If you need more help/review, you can contact Mikko about that.

singen12:03:15

I think I can free myself around 16 and I’m stationed nearby