Skip to content

Commit

Permalink
fixup! feat: implement first crate version
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Sep 10, 2022
1 parent 97ecc99 commit af4d5d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/models/property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ impl<'a> Serialize for Property<'a> {
if data_schema.title.is_some() {
map.serialize_entry("title", data_schema.title.unwrap())?;
}
if data_schema.data_type.is_some() {
map.serialize_entry("type", &data_schema.data_type)?;
}

map.end()
}
Expand Down
9 changes: 6 additions & 3 deletions src/models/thing_description.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ mod tests {
use crate::{
data_structures::{array::ArrayEntry, map::MapEntry},
models::{
action::Action, data_schema::DataSchema, link::Link, property::Property,
action::Action,
data_schema::{DataSchema, DataType},
link::Link,
property::Property,
thing_description::ThingDescriptionBuilder,
},
};
Expand Down Expand Up @@ -215,7 +218,7 @@ mod tests {
read_only: None,
write_only: None,
format: None,
data_type: None,
data_type: Some(DataType::Boolean),
},
},
);
Expand All @@ -231,7 +234,7 @@ mod tests {
.links(links)
.build();

let expected_result = r#"{"@context":"https://www.w3.org/2022/wot/td/v1.1","@type":["saref:LightSwitch"],"title":"Test TD","properties":{"status":{"title":"Status"}},"actions":{"toggle":{"input":{"title":"Toggle Data"}},"toggle2":{}},"links":[{"href":"https://example.org"}]}"#;
let expected_result = r#"{"@context":"https://www.w3.org/2022/wot/td/v1.1","@type":["saref:LightSwitch"],"title":"Test TD","properties":{"status":{"title":"Status","type":"boolean"}},"actions":{"toggle":{"input":{"title":"Toggle Data"}},"toggle2":{}},"links":[{"href":"https://example.org"}]}"#;
let actual_result: String<300> = to_string(&thing_description)?;

assert_eq!(expected_result, actual_result.as_str());
Expand Down

0 comments on commit af4d5d6

Please sign in to comment.