-
Notifications
You must be signed in to change notification settings - Fork 225
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
rocket_ext fails to generate params properly when generic IntoParams are repeated #603
Comments
This issue also only occurs if you use the generic as the type in the function argument list. |
This appears to be the culprit, at least indirectly. Since it's the only thing that discriminates based on being a generic. utoipa/utoipa-gen/src/ext/rocket.rs Lines 134 to 136 in 489ddd6
My guess is that we've run afoul of some basic heuristic breaking down. Like "If it's a generic, then it's a Rocket guard and not an actual parameter" |
Yeah, I think there is no "quick" fix for this. At the moment the Then why there is no generics support on This issue is not only limited to the rocket but it also exists from the beginning of So far the only cure is to implement |
Hey @juhaku thanks for taking the time to respond. I think there may be some confusion, either on your end or mine. The issue I'm having has nothing to do with the #[utoipa::path(get, path="/{foo}",
params(
Foo::<Opaque>,
Foo::<i32>,
),
)]
pub async fn example(foo: Foo<Opaque>) -> String {
"hi".into()
} Using generic concrete instantiations for |
Aah, okay, that might be my bad. There probably is some room to improve this in rocket but the rocket support is not super straight forward. I am beginning to remeber what this is all about. The thing in rocket is that path and query args are all "unwrapped". They are not being wrapped to another container type such as
As you stated earlier, you are absolutely right. The logic used to determine the parameters might just need revising. Yet this is not simple, as the big open question lies in front of us that how to distinct the parameters from rocket guards just based on the argument name or type name? There is no compile time evaluation of what traits are being implemented for the arguments based on tokens only. |
I'm not entirely sure exactly why this happens but here's a minimal repro:
and the error message:
If we expand the macro using rust-analyzer we get the following expansion:
Notably the problem occurs here:
Where no closure is passed to
into_params
.This issue only occurs when the
params
tuple contains a repeat of the same generic type (in this caseFoo
). You may ask why you would want to do this, but we have an impl block that looks like:Where each possible T produces a different set of params.
This issue also only occurs when integrating with rocket. This problem dates back to at least utopia 3.1.0 and rocket 5.0.rc2 but it repros on utopia 3.3.0 and rocket 5.0.rc3.
The text was updated successfully, but these errors were encountered: