yada

mmer 2018-03-05T16:50:33.000156Z

Is there a way to generate a ya da server from a swagger definition?

borkdude 2018-03-05T17:10:15.000730Z

no

jholkeboer 2018-03-05T19:42:20.000220Z

How to i tell yada which http status code to return, depending on the request content? Or depending on what error is caught?

jholkeboer 2018-03-05T19:42:26.000576Z

I've been looking at this page: https://github.com/juxt/yada/blob/master/doc/responses.adoc

jholkeboer 2018-03-05T19:44:02.000514Z

i tried "declaring" a 400 in my handler, and returning {400 "message}, but it just returned a 200 with {400 "message"} as the body

danielcompton 2018-03-05T21:26:38.000395Z

@jholkeboer there's different ways depending on how much control you need

danielcompton 2018-03-05T21:27:13.000113Z

If you follow the happy path of yada, then you never need to explicitly set status codes as it will do it all for you, based on it's understanding of the HTTP spec

danielcompton 2018-03-05T21:27:31.000454Z

e.g. if a form request doesn't pass the Schema then it will return a 400 without you having to do anything

danielcompton 2018-03-05T21:31:04.000060Z

https://juxt.pro/yada/manual/index.html#responses

danielcompton 2018-03-05T21:31:19.000035Z

I had to read this a few times to really get it, I would like to make a PR to explain it better

danielcompton 2018-03-05T21:33:13.000151Z

There are three ways to return a response, explicit responses, declared responses, and status responses

danielcompton 2018-03-05T21:33:45.000415Z

Explicit responses let you return the full response from the context (assoc (:response ctx) :status 418) along with any response you would like

danielcompton 2018-03-05T21:34:45.000499Z

A status response is used for overriding Yada's default responses for a particular status code

danielcompton 2018-03-05T21:35:17.000489Z

So if you would have got a 404 for a particular request, you can override the 404 response with your own response entry

danielcompton 2018-03-05T21:35:48.000044Z

There is a difference between 10.2 Declared responses and 10.3 Status responses, but I can't remember what they are

danielcompton 2018-03-05T21:36:38.000538Z

For you, you probably want to use Schema validation if you can validate the request being bad up front