We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
If you set a router class on the Router, the versioned class doesn't receive the same router class.
Python 3.11.7 Ubuntu 20 fastapi-versionizer 3.0.4
class CustomRoute(APIRoute): def get_route_handler(self) -> Callable: original_route_handler = super().get_route_handler() async def custom_route_handler(request: Request) -> Response: print("debug") return await original_route_handler(request) return custom_route_handler users_router = APIRouter( prefix='/users', tags=['Users'], route_class=CustomRoute, ) @api_version(1) @users_router.get('') def get_users() -> List[User]: return list(db.users.values())
It should identify the route class isn't the default APIRoute and pass it as a parameter to router.add_api_route(**kwargs).
router.add_api_route(**kwargs)
The custom_route_handler is never called because the Route class is always APIRoute.
custom_route_handler
I changed these lines on versionizer, and it worked. Is there any other way to resolve this?
@staticmethod def _add_route_to_router( route: Union[APIRoute, APIWebSocketRoute], router: APIRouter, version: Tuple[int, int] ) -> None: kwargs = dict(route.__dict__) if route.__class__ != APIRoute: # <--- kwargs['route_class_override'] = route.__class__ # <---
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Subject of the issue
If you set a router class on the Router, the versioned class doesn't receive the same router class.
Your environment
Python 3.11.7
Ubuntu 20
fastapi-versionizer 3.0.4
Steps to reproduce
Expected behaviour
It should identify the route class isn't the default APIRoute and pass it as a parameter to
router.add_api_route(**kwargs)
.Actual behaviour
The
custom_route_handler
is never called because the Route class is always APIRoute.I changed these lines on versionizer, and it worked. Is there any other way to resolve this?
The text was updated successfully, but these errors were encountered: