I was following the <OpenAPI example>, and sending...
# http4k
n
I was following the OpenAPI example, and sending an invalid request body to the echo endpoint (e.g.
Copy code
Request(Method.POST, "/echoJson").body("""{"name": "Test"}""")
) returns this rather generic
{"message":"Missing/invalid parameters","params":[{"name":"body","type":"body","datatype":"object","required":true,"reason":"Invalid"}]}
. Is there an easy (or hard) way to get a more detailed error message? I tried adding a CatchLensFilter, but it looks like the contract renderer(?) already catches and handles that. the closest I've found to an answer is this 2023 slack thread
d
So there are a couple of bits to this. • You can replace the renderer implementation inside the open API machinery to change the response. • The actual error will be buried inside the lens failure exception cause.
The Jackson stack trace is readable but not parseable AFAIK, so we can't be more specific with the error
The "style" of the error is the same across all pens targets which is why it looks somewhat odd when referencing a body. it's much more obvious for headers etc...
n
Thanks, that helps. It looks like
Copy code
private val errorResponseRenderer: ErrorResponseRenderer = JsonErrorResponseRenderer(json),
would be the thing to override?
d
yep
thank you color 1