Fork me on GitHub
#ring-swagger
<
2016-02-10
>
sreenath.n12:02:01

I am using schema to validate email format (`#".+@.+”`) in the request. I am not a able to find a way to provide a custom message, incase schema validation fails… Any ideas?

sreenath.n12:02:05

this is what I have now, ...`:body [user {:user {:email #".+@.+"}}]`...

bitsai18:02:57

@sreenath.n: one option is to use schema's (pred) function, which can take an optional predicate name for slightly nicer validation errors

bitsai18:02:11

is there a way to specify response examples using either compojure-api or ring-swagger?

bitsai18:02:51

i saw that it's possible to specify multiple response schemas using :responses, but am looking for a way to specify concrete response examples

ikitommi19:02:00

@bitsai I think not at the moment. But should. Could you like to do a PR of it?

ikitommi19:02:39

… just another key on the schema meta-data or could be something more useful - a mechanism to verify that the samples are valid against the schema.

ikitommi19:02:25

Same a default-values, there will be proper support (via coercion) to those in schema-tools, and will be part of schema-tools. Now just used for documentation.

ikitommi19:02:58

and there should be a way to put these all together in a more declarative way, imo.

bitsai23:02:19

@ikitommi: problem solved! our goal was to quickly create a mock api that the frontend can start talking to while the api server was still being built

bitsai23:02:31

we figured out that once we had the response schemas in place, we could import the generated swagger.json into http://apiary.io

bitsai23:02:55

which took care of generating a mock server for us (it knows how to generate mock responses using the response schemas)