Split parsing from validation completely#1934
Conversation
|
Hi @RobbeSneyders, thanks a lot for looking into my PR and providing this change, which seems to make a lot of change! Trying it out, I found that it only applies to path and query params, and not to header params. Parameter validator gets request.headers, which, on further investigation, is not a property of ConnexionRequest, but only exposes the headers property of the underlying Starlette request object. On this, no type conversion is being done, so I'm now seeing the exact same issue as before. Trying to fix this by adding a header_params property to ConnexionRequest, I stumbled over more issues. For some reason, I don't know whether that is a bug in Connexion or a misconfiguration on my side, the URIParser used in the ConnexionRequest doesn't have the param_defn from the API spec, so it skips the type conversion. I decided to stop the migration effort here for a while as it's been taking too much time already. This is just to inform you about the things I've noticed. |
During the refactoring for Connexion 3, we deduplicated all
coerce_typecalls during the refactoring and moved them into theuri_parserso it is done in a single place. When looking into #1931 however, I noticed we are still using theuri_parserfrom more places than we should.This PR centralizes the parsing further into the
ConnexionRequestclass. During validation, we now instantiate aConnexionRequestinstead of a StarletteRequest, and leverage it instead of calling theuri_parserdirectly.I split the parsing and validation in the tests so they can be tested in isolation.