-
Notifications
You must be signed in to change notification settings - Fork 230
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
schema creation fails when field has a module-qualified type (at least when using axum) #569
Comments
This looks similar to #164, but that's about responses and this is about schema. |
Er... the above workaround does not actually seem to work in this case; I'm not sure why, but I still get the red Errors box. In my actual project I have a similar workaround and that works fine. |
For this there is a need to use #[derive(ToSchema)]
#[as = commentary::Commentary]
struct Commentary {
value: String,
}
// .. in another type and module we can use the module path now.
#[derive(ToSchema)]
struct Foo {
comments: commentary::Commentary,
} |
Do you mean this?
That does seem to do the trick in the example. I'll check with the "real" project and report back. |
Yes |
The real-world usage prompted a hiccup, because some crates import the type, and others import only its crate. To illustrate, suppose I modify the
Now it's the un-qualified
...and I can work with this. Thank you! |
Version
latest
Description
See subject. (Sorry if I'm using the wrong terminology for "module-qualified type".)
Expected behavior
Schemas should be created even for module-qualified types.
MWE
Add the following to the utoipa-axum example:
then the following import to
mod todo
:and then the following field to
struct Todo
:Everything compiles and runs happily, but schema creation has failed. If you open the first endpoint or the
Todo
schema you get a red box listing the following error:A workaround is to
use super::commentary::Commentary
but this is suboptimal for large projects where, for instance, you may be importing differentCoordinate
s from different crates.The text was updated successfully, but these errors were encountered: