connexion
connexion copied to clipboard
Sort routes in RoutingMiddleware
Fixes #1879
Please let me know if this is the correct place to perform the sort or if any more changes are needed.
I've ran into this issue while migrating a large API from connexion 2 to connexion 3 (Async app variant) and the changes implemented here fixed route mismatching.
Thanks @kosciCZ, I think we need to update this in the AbstractRoutingMiddleware
though.
Hi @kosciCZ, do you have time to have another look at this?
@RobbeSneyders sorry about that, yes, definitely. Could you throw me some pointers on the general outline of the solution?
My idea with this was that this is mostly Starlette specific, since their route matching iterates over routes and performs regex matches until a match is found, so order is important. With Flask, this does not seem to be an issue (our API on sync connexion 2.x matched routes correctly without having to sort them). So, that's why I chose to sort them all after the routes have been mounted, as that seemed like the appropriate place. Would you like me to replicate that in the method you referenced?
@RobbeSneyders any thoughts on ^?
Hi @kosciCZ, I would prefer to update it in the AbstractRoutingMiddleware
, so the behavior is consistent across all places where we are routing requests, even if the resulting behavior is the same.