-
Notifications
You must be signed in to change notification settings - Fork 220
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
Type aliases not being resolved correctly #429
Comments
Hey, This is because during parsing the AST we do not know what is the actual type of One alternative to type aliases here would be using a new type pattern, but that also adds another layer of indirection to the types. This would introduce another layer of boilerplate that one might need to implement for the new type to be able to access to the underlying type properties more elegantly. Type aliases in general are quite hard thing in the utoipa world. |
This PR adds global config for `utiopa` which allows defining global Rust type aliases that can be recognized by `utoipa`. ```rust let _ = Config::new() .alias_for("MyType", "i32"); .alias_for("Json", "Value"); .alias_for("NullableString", "Option<String>"); ``` Closes #984 Closes #787 Closes #766 Closes #429
Using the type alias
Leads to any serialized struct field having the type:
Directly specifying the type as
DateTime<Utc>
in the struct leads to the type being correctly resolved. (type shows asdate-time
)The text was updated successfully, but these errors were encountered: