~Just beginning to learn the codebase, but excited to contribute something substantial in the future 😄
Currently, routes with duplicate path parameters can be registered to a handler. The conflict is resolved by using the value associated to the last occurrence of the duplicated parameters (see here).
I would think an exception should be raised when registering the route, or at least that's the behavior I'm used to seeing. The test below currently passes, as a demonstration.
A simple change when creating the kwargs model that checks for repeated params. Currently param names are added to a set without checking for repeats.
def create_handler_kwargs_model(self, route_handler: BaseRouteHandler) -> KwargsModel:
"""
Method to create a KwargsModel for a given route handler
"""
dependencies = route_handler.resolve_dependencies()
signature_model = get_signature_model(route_handler)
path_parameters = set()
for param in self.path_parameters:
param_name = param["name"]
if param_name in path_parameters:
raise ImproperlyConfiguredException(
f"Duplicate path parameters should not be used. Duplicate parameter {{{param_name}}} found in path {self.path}"
)
path_parameters.add(param_name)
return KwargsModel.create_for_signature_model(
signature_model=signature_model, dependencies=dependencies, path_parameters=path_parameters
)
Happy to push this, I just still have a very shallow grasp of the codebase so am probably not doing this the best way!
~Just beginning to learn the codebase, but excited to contribute something substantial in the future 😄
Currently, routes with duplicate path parameters can be registered to a handler. The conflict is resolved by using the value associated to the last occurrence of the duplicated parameters (see here).
I would think an exception should be raised when registering the route, or at least that's the behavior I'm used to seeing. The test below currently passes, as a demonstration.
Current behavior
Proposed behavior
Possible fix
A simple change when creating the kwargs model that checks for repeated params. Currently param names are added to a set without checking for repeats.
Happy to push this, I just still have a very shallow grasp of the codebase so am probably not doing this the best way!