@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?
@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.
@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.
@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"
]
}
oh, I've also altered the handler to return true
rather than {success: true}
. So I'm starting to think this is a bug
@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
@ikitommi Gist at https://gist.github.com/marrs/bded1dfa0b97893610b48b181b6fb50a
I'll post an issue on github tomorrow