You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let value = EqExpr::Eq(PathInfo {
path: "age".to_string(),
value: json!(20),
});
// Serialise with serde
dbg!(serde_json::to_string(&value).unwrap());
// Prints: "{\"@eq\":{\"path\":\"age\",\"value\":20}}"
// Serialise with poem
dbg!(&value.to_json_string());
// Prints "{\"path\":\"age\",\"type\":\"@eq\",\"value\":20}"
let value = EqExpr::NotEq(PathInfo {
path: "age".to_string(),
value: json!(20),
});
// Serialise with serde
dbg!(serde_json::to_string(&value).unwrap());
// Prints "{\"@neq\":{\"path\":\"age\",\"value\":20}}"
// Serialise with poem
dbg!(&value.to_json_string());
// Prints "{\"path\":\"age\",\"type\":\"@neq\",\"value\":20}"
This is good and dandy, poem does not support externally tagged enums, but the "type": "..." acts as the discriminator.
let value = EqExpr::Eq(vec![PathInfo {
path: "age".to_string(),
value: json!(20),
}]);
// Serialise with serde
dbg!(serde_json::to_string(&value).unwrap());
// Serialise with poem
dbg!(&value.to_json_string());
let value = EqExpr::NotEq(vec![PathInfo {
path: "age".to_string(),
value: json!(20),
}]);
// Serialise with serde
dbg!(serde_json::to_string(&value).unwrap());
// Serialise with poem
dbg!(&value.to_json_string());
As can be seen, with serde the externally discrimination of the enums, makes it possible to differentiate between the two enums, but with poem, both prints [{\"path\":\"age\",\"value\":20}].
Expected Behavior
poem should not serialise both of the enum variants into the same json string representation.
Because of this, it is also impossible to deserialise into the rust enums.
Specifications
Version:
poem = { version = "2.0.0" }
poem-openapi = { version = "4.0.0", features = ["swagger-ui", "uuid"] }
Platform:
~ uname -a
Darwin DeeMBP2773 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000 arm64
The text was updated successfully, but these errors were encountered:
Actual Behavior
Given this enum
Serialising with both serde and poem
This is good and dandy, poem does not support externally tagged enums, but the
"type": "..."
acts as the discriminator.Now if the enum is changed to the following:
Then serialised like this
it prints:
As can be seen, with
serde
the externally discrimination of the enums, makes it possible to differentiate between the two enums, but with poem, both prints[{\"path\":\"age\",\"value\":20}]
.Expected Behavior
poem should not serialise both of the enum variants into the same json string representation.
Because of this, it is also impossible to deserialise into the rust enums.
Specifications
poem = { version = "2.0.0" }
poem-openapi = { version = "4.0.0", features = ["swagger-ui", "uuid"] }
~ uname -a
Darwin DeeMBP2773 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000 arm64
The text was updated successfully, but these errors were encountered: