We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I've an element that accepts a text body defined as follow
#[derive(PartialEq, Debug, YaSerialize, YaDeserialize, Default)] #[yaserde( rename = "capability", namespace = "urn:ietf:params:xml:ns:netconf:base:1.0" )] pub struct Capability { #[yaserde(text)] pub body: String, }
And I can successfully serialize/deserialize it
#[test] fn test_capability() { let input_str = r#"<?xml version="1.0" encoding="utf-8"?> <capability xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">urn:ietf:params:netconf:base:1.1</capability>"#; let expected = Capability { body: "urn:ietf:params:netconf:base:1.1".to_string(), }; let parsed: Capability = from_str(&input_str).unwrap(); let serialized = to_string_pretty(&parsed).unwrap(); assert_eq!(parsed, expected); assert_eq!(serialized, input_str); }
However when I try to use in a vector of another element, it fails expecting the inner element to be defined
#[derive(PartialEq, Debug, YaSerialize, YaDeserialize, Default, Serialize, Deserialize)] #[yaserde( rename = "hello", namespace = "urn:ietf:params:xml:ns:netconf:base:1.0" )] pub struct Hello { #[yaserde(child, rename = "capabilities")] pub capabilities: Vec<Capability>, #[yaserde(child, rename = "session-id")] pub session_id: Option<u32>, } #[test] fn test_hello() { let content = r#" <hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <capabilities> <capability> urn:ietf:params:netconf:base:1.1 </capability> <capability> urn:ietf:params:netconf:capability:startup:1.0 </capability> <capability> http://example.net/router/2.3/myfeature </capability> </capabilities> <session-id>4</session-id> </hello> "#; let loaded: Hello = from_str(&content).unwrap(); let expected = Hello { session_id: Some(1), capabilities: vec![ Capability { body: "urn:ietf:params:netconf:base:1.1".to_string(), }, Capability { body: "urn:ietf:params:netconf:capability:startup:1.0".to_string(), }, Capability { body: "http://example.net/router/2.3/myfeature".to_string(), }, ], }; assert_eq!(loaded, expected); let loaded_str = to_string_pretty(&loaded).unwrap(); assert_eq!(loaded_str, content); }
I get the following error: called Result::unwrap()on anErr value: "body is a required field of Capability"
called
on an
value: "body is a required field of Capability"
The text was updated successfully, but these errors were encountered:
Getting the same error here as well
Sorry, something went wrong.
No branches or pull requests
I've an element that accepts a text body defined as follow
And I can successfully serialize/deserialize it
However when I try to use in a vector of another element, it fails expecting the inner element to be defined
I get the following error:
called
Result::unwrap()on an
Errvalue: "body is a required field of Capability"
The text was updated successfully, but these errors were encountered: