#[derive(utoipa::ToSchema)]
struct Foo {
bar: <Self as Dummy>::Zing,
}
trait Dummy {
type Zing;
}
impl Dummy for Foo {
type Zing = String;
}
Results in:
error[E0223]: ambiguous associated type
--> src/main.rs:4:19
|
4 | bar: <Self as Dummy>::Zing,
| ^^^^^^^^^^^^
|
help: use fully-qualified syntax
|
4 | bar: <Self as <Foo as Dummy>::Zing,
| +++++++
Relevant output of cargo expand:
impl utoipa::ToSchema for Foo {
fn name() -> std::borrow::Cow<'static, str> {
std::borrow::Cow::Borrowed("Foo")
}
fn schemas(
schemas: &mut Vec<
(String, utoipa::openapi::RefOr<utoipa::openapi::schema::Schema>),
>,
) {
schemas
.extend([
(
String::from(
::alloc::__export::must_use({
::alloc::fmt::format(
format_args!(
"{0}",
<Dummy::Zing as utoipa::ToSchema>::name(),
),
)
}),
),
<Dummy::Zing as utoipa::PartialSchema>::schema(),
),
]);
<Dummy::Zing as utoipa::ToSchema>::schemas(schemas);
}
}
Note the multiple occurences of <Dummy::Zing as utoipa::ToSchema>. where the Self as is completely dropped.
The problem is here:
|
TypeTreeValue::TypePath(type_path) => &type_path.path, |
Only the .path is accessed, ignoring the type_path.qself. I tried to fix it myself but it's not trivial as many own types in utoipa-gen (e.g. TypeTree) contain Path so all of those would be need to changed to TypePath to carry along the Self as. I did try that but then run into some other problems where I was lacking knowledge about the code base to proceed.
Would be great if this is fixed :) Thanks!
Results in:
Relevant output of
cargo expand:Note the multiple occurences of
<Dummy::Zing as utoipa::ToSchema>. where theSelf asis completely dropped.The problem is here:
utoipa/utoipa-gen/src/component.rs
Line 297 in dcdf087
Only the
.pathis accessed, ignoring thetype_path.qself. I tried to fix it myself but it's not trivial as many own types inutoipa-gen(e.g.TypeTree) containPathso all of those would be need to changed toTypePathto carry along theSelf as. I did try that but then run into some other problems where I was lacking knowledge about the code base to proceed.Would be great if this is fixed :) Thanks!