diff --git a/connexion/middleware/abstract.py b/connexion/middleware/abstract.py index 64b6e7c34..5fe5def0c 100644 --- a/connexion/middleware/abstract.py +++ b/connexion/middleware/abstract.py @@ -10,6 +10,7 @@ from connexion.operations import AbstractOperation from connexion.resolver import Resolver from connexion.spec import Specification +from connexion.utils import sort_routes logger = logging.getLogger(__name__) @@ -85,7 +86,8 @@ def add_paths(self, paths: t.Optional[dict] = None) -> None: Adds the paths defined in the specification as operations. """ paths = t.cast(dict, paths or self.specification.get("paths", dict())) - for path, methods in paths.items(): + for path in sort_routes(list(paths.keys())): + methods = paths[path] logger.debug("Adding %s%s...", self.base_path, path) for method in methods: