Fork me on GitHub
#ring-swagger
<
2016-10-06
>
ikitommi07:10:34

good to hear you got it working!

sickill10:10:32

is it possible to set example value for a required :body-param in compojure-api?

ikitommi10:10:06

@sickill yes, you can attach extra data into Schemas via ring-swagger, there is an example of example 😉 in https://github.com/metosin/ring-swagger#example

sickill10:10:44

so instead of :body-params [query :- String] I do :body-params [query :- (rjs/field String {:example "blah blah"})]?

ikitommi10:10:56

hmm… I think the swagger-spec doesn’t have a example on individual fields at the moment, just for the schemas.

ikitommi10:10:16

just re-browsed http://swagger.io/specification/, coudn’t find an example.

ikitommi10:10:20

but, they work with map-schemas, so you can say: :body [body (rjs/field MyBodyMapSchema {:example {:a 1, :b 2}})]

ikitommi10:10:54

If you find a way to do that with swagger, happy to patch ring-swagger to support it.

sickill11:10:39

I think that's good enough

ikitommi11:10:35

@sickill oh, but forgot. there is the default for the params: (rjs/field String {:default “blah blah"})

sickill11:10:03

ikitommi great, that worked (I thought default is completely ignored for required fields)