Fork me on GitHub
#ring-swagger
<
2016-12-27
>
petr.mensik13:12:35

Is there a way how to document path or query params with Swagger? I have API like this :query-params [{approved :- s/Bool true}] so is it possible to document it?

ikitommi15:12:01

@petr.mensik you can add documentation to the type via ring-swagger, see here: https://github.com/metosin/ring-swagger#adding-description-to-schemas

ikitommi15:12:09

and there is a describe in compojure.api.sweet for this.

petr.mensik21:12:18

Cool, thank you, however I cannot get it work the way I want. My param is like this :query-params [approved :- (describe s/Bool "Desc" :required false :default true)] - what I want is to fallback to true if the client won't provide the param. However I am getting back exception message with missing-required-key when I don't provide it

petr.mensik21:12:19

However Swagger docs is correct, drop down also allows to enter empty value and true is the default

juhoteperi21:12:44

:query-params [{approved :- (describe s/Bool "Desc") true}] you should use describe together with letk default binding

juhoteperi21:12:31

describe can generate correct JSON-Schema for required and default properties, but it doesn't affect Schema validation on Clojure side

petr.mensik21:12:46

ahaaa, thanks a lot 🙂 sorry for beginner questions, it's still sometimes hard to read others code