utoipa: v3.4.0 requires IntoParams for actix path parameter types, breaking newtype pattern
On updating to v3.4.0, I get a lot of errors like
error[E0277]: the trait bound `FooId: IntoParams` is not satisfied
--> services/blah/src/routes/baz.rs:34:21
|
34 | foo_id: Path<FooId>,
| ^^^^^^^^ the trait `IntoParams` is not implemented for `FooId`
where FooId is a newtype wrapper around uuid. c.f. https://github.com/juhaku/utoipa/discussions/655
Now the fun part is when adding IntoParams to FooId, I get
error: struct with unnamed fields must have explicit name declarations.
= help: Try defining `#[into_params(names(...))]` over your type: FooId
--> rust/models/src/lib.rs:2673:16
|
2673 | pub struct FooId(pub uuid::Uuid);
| ^^^^^^^
Note this is code that all worked with v3.3.0.
In the route function definition, I have the name of the single path variable : foo_id: Path<FooId> - this approach means the function signature describes the parameter names.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 15 (11 by maintainers)
Commits related to this issue
- Disable automatic parameter recognition Temporarily disable automatic parameter recognition. This is to mitigate the current issues in `IntoParams` implementation furhter discussed in issues #675 #67... — committed to juhaku/utoipa by juhaku a year ago
- Disable automatic parameter recognition (#696) Temporarily disable automatic parameter recognition. This is to mitigate the current issues in `IntoParams` implementation furhter discussed in issues... — committed to juhaku/utoipa by juhaku a year ago
- Disable automatic parameter recognition (#696) Temporarily disable automatic parameter recognition. This is to mitigate the current issues in `IntoParams` implementation furhter discussed in issues... — committed to lithiumFlower/utoipa by juhaku a year ago
Oh snap, I knew it that when I make the release there will be something that will not work as expected. I’ll try to fix this asap.
The old behavior for path and query parameters is restored here #696 to allow furhter releases from the master branch. The improved
IntoParamsneeds furhter planning and experiementing before it can be fully implemented which might take some time. With this I am going to make a release 3.4.1 with the changes soon.Anytime,
Yeah this is unfortunate breaking change release that should have been 4.0.0. But on the bright side it let us know what is lacking in sense of functionality from the current implementation. You are probably right it’s better yank the 3.4.0 until it causes more trouble for more people. I might as well for the next release go the whole nine yards to improve the
IntoParamsimplementation. However it not going to change the fact thatIntoParamsmust be derived or otherwise implemented for query or path parameters that so require. These are types that are not commonly recognized as primitive types.