-
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
Question Compilation error: ToSchema called Option::unwrap()
on a None
value
#543
Comments
This is my code, although alot of type aliases - they are mostly strings and maps: use utoipa::ToSchema;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)]
#[serde(tag = "type")]
#[derive(ToSchema)]
pub struct AggregationRequest {
// general fields
#[serde(default)]
pub name: Option<String>,
/// Measure: (Name, Action) where Name will be looked up in
/// MeasuresMap of the DataSet
pub measures: Vec<(MeasureName, AggregationName)>,
pub groupby: Vec<String>,
#[serde(default)]
pub filters: AndOrFltrChain,
#[serde(default)]
pub overrides: Vec<Override>,
#[serde(default, alias = "additionalRows")]
pub add_row: AdditionalRows,
#[serde(default)]
pub calc_params: CPM,
/// drop rows where all results are NULL or 0
#[serde(default)]
pub hide_zeros: bool,
/// Show totals
#[serde(default)]
pub totals: bool,
} |
This is coming from the tuple syntax within your struct and is related to #330, #391, #176 and is fixed in #541.
Tuple support will be available after next release, but can be accessed now by pointing the cargo dependency to the master for time being. |
@juhaku great, thank you very much. |
@juhaku , sorry, another issue followed directly from that one. Happy to put it in a separate issue though if that helps. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)]
#[serde(untagged)]
#[cfg_attr(feature = "openapi", derive(ToSchema))]
pub enum ComputeRequest {
Aggregation(AggregationRequest),
Breakdown,
} This fails to compile with:
|
We can continue on this thread as well. 🙂 Interesting, that still does not tell enough what is going on. How does the |
@juhaku thanks for quick reply. I will put together a proper reproducible example. |
@juhaku , here we go: use serde::Deserialize;
use serde::Serialize;
pub fn example() {
()
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash, utoipa::ToSchema)]
#[serde(tag = "type")]
pub struct AggregationRequest {
#[serde(default)]
pub name: Option<String>,
pub measures: Vec<(String, String)>
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash, utoipa::ToSchema)]
#[serde(untagged)]
pub enum ComputeRequest {
Aggregation(AggregationRequest),
Breakdown,
} And: serde = { version="*", features = ["derive", "rc"] }
serde_json = { version="*" }
utoipa = { git ="https://github.com/juhaku/utoipa", features = ["actix_extras"] } |
Option::unwrap()
on a None
value
Thanks for the example 🙂 , This makes me wonder why the parsing is getting to this point where it is now giving error.
I need to investigate what is going on here, this scenario should be possible to my knowledge 🤔 |
Moreover it is caused by the
|
@AnatolyBuga And there you go, fix is on the way landing to master soon by #545. |
@juhaku thank you so much for promptly fixing this, and for the whole amazing library too. |
I am getting an error on
As far as I can see ToShema derive doesn't take any arguments. Any thoughts?
The text was updated successfully, but these errors were encountered: