-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: handle same field name but different namespace
issue #186
- Loading branch information
1 parent
e4aff84
commit a067b85
Showing
6 changed files
with
76 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ mod bbigras_namespace; | |
mod boscop; | ||
mod generic; | ||
mod ln_dom; | ||
mod same_element_different_namespaces; | ||
mod svd; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// related to issue https://github.com/media-io/yaserde/issues/186 | ||
use yaserde::*; | ||
|
||
#[derive(YaDeserialize, Debug, PartialEq)] | ||
#[yaserde( | ||
namespace = "myns: http://my_namespace_1/", | ||
namespace = "ext: http://my_namespace_2/", | ||
prefix = "myns" | ||
)] | ||
pub struct ErrorType { | ||
#[yaserde(rename = "reasonCode", prefix = "myns")] | ||
pub reason_code: Option<u16>, | ||
#[yaserde(rename = "reasonCode", prefix = "ext")] | ||
pub ext_reason_code: Option<u16>, | ||
} | ||
|
||
#[test] | ||
fn same_element_different_namespaces() { | ||
use yaserde::de::from_str; | ||
|
||
let content = r#" | ||
<error_type xmlns="http://my_namespace_1/" xmlns:ext="http://my_namespace_2/"> | ||
<reasonCode>12</reasonCode> | ||
<ext:reasonCode>32</ext:reasonCode> | ||
</error_type> | ||
"#; | ||
|
||
let loaded: ErrorType = from_str(content).unwrap(); | ||
println!("{:?}", loaded); | ||
|
||
let reference = ErrorType { | ||
reason_code: Some(12), | ||
ext_reason_code: Some(32), | ||
}; | ||
|
||
assert_eq!(loaded, reference); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters