Fork me on GitHub
#reitit
<
2020-03-17
>
marrs15:03:49

@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?

ikitommi16:03:13

@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.

marrs17:03:13

@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.

👌 4
marrs18:03:53

@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"
  ]
}

marrs18:03:04

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

ikitommi18:03:12

@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

marrs23:03:43

I'll post an issue on github tomorrow