-
-
Notifications
You must be signed in to change notification settings - Fork 767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix/basepath #1716
Bugfix/basepath #1716
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Ruwann!
This approach looks good to me. Unless I'm missing something, I don't think we're sorting paths without path parameters correctly though?
Eg. if you look at the example in the issue, we should also sort "/swagger"
before "/"
. I think this is only necessary for the APIs, not for individual routes, but I don't think it has any downside there.
connexion/utils.py
Outdated
class SortableRoute: | ||
def __init__(self, path: str) -> None: | ||
self.path = path | ||
self.path_regex, _, _ = compile_path(path) | ||
|
||
def __lt__(self, other: "SortableRoute") -> bool: | ||
return bool(other.path_regex.match(self.path)) | ||
|
||
return sorted(routes, key=lambda r: SortableRoute(key(r) if key else r)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smart 🤯
Thanks, good catch. Indeed, this was not yet working properly because the tests added the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Ruwann!
Working towards #1709
I think we're almost there, some tests I did are now working properly.
Would love to get some feedback/ideas on the implementation and the tests :)