reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
marrs 2020-03-17T15:36:49.077300Z

@ikitommi thanks, that will help me later on, but actually for now I'm just trying to get a body with all those properties defined to pass validation. So does that mean that that error suggests that I am getting a nil body?

ikitommi 2020-03-17T16:45:13.080200Z

@d.marrs the body is either not set or the Content-Type header is not valid and not triggering the automatic body parsing. Could also be that you don’t have any middleware in the chain to do the body-parsing. I recommend to check out the examples, those have both the required chain on middleware for content-negotiation & body-parsing & commented out the debugging flags to see what is actually happening in the middleware chain. Hope this helps.

marrs 2020-03-17T17:22:13.082800Z

@ikitommi I'm not sure what the issue was but it resolved itself. I did have some middleware commented out, and I also have middleware shared between two routers that have been merged together. I think what happened is that I uncommented that correct middleware but that it wasn't detected straight away. I have no idea why that would be the case, but literally what happened is that I left it for 15 mins to clear my head, tried to think about what I was going to do to debug the issue, re-ran the request and got a 200 response.

👌 1
marrs 2020-03-17T18:38:53.085100Z

@ikitommi it may have been the response rather than the request that was causing the problem. It turns out that if I turn :responses from

:responses {
          200 {:body {:success s/Bool}}
        }
to
:responses {
          200 {:body s/Bool}
        }
then I get the same 400 error message as above:
{
  "schema": {
    "a": "java.lang.String",
    "(opt :b)": "java.lang.String",
    "c": "java.lang.String",
    "d": "java.lang.String",
    "(opt :e)": "java.lang.Boolean"
  },
  "errors": "(not (map? nil))",
  "type": "reitit.coercion/request-coercion",
  "coercion": "schema",
  "value": null,
  "in": [
    "request",
    "body-params"
  ]
}

marrs 2020-03-17T18:43:04.086Z

oh, I've also altered the handler to return true rather than {success: true}. So I'm starting to think this is a bug

ikitommi 2020-03-17T18:55:12.087700Z

@d.marrs the error says it's request coercion, not related to responses. If you can provide a failing minimal repro, I can take a look

marrs 2020-03-17T23:13:43.088400Z

I'll post an issue on github tomorrow