Skip to content

Commit

Permalink
add multiple keyword to syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-1991 committed Sep 8, 2024
1 parent cb1fa2f commit d688639
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ impl Attribute {
"description" => self.docstring = option.value,
"xml" => self.set_xml(XMLType::from_str(&option.value).expect("Invalid XML type")),
"default" => self.default = Some(DataType::from_str(&option.value)?),
"multiple" => self.is_array = option.value.to_lowercase() == "true",
_ => self.options.push(option),
}

Expand Down
15 changes: 15 additions & 0 deletions tests/data/model_multiple_keyword.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
id-field: true
repo: "https://www.github.com/my/repo/"
prefix: "tst"
prefixes:
schema: http://schema.org/
nsmap:
tst: http://example.com/test/
---

### Test

- name
- Type: string
- Multiple: True
14 changes: 14 additions & 0 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,18 @@ mod tests {
assert_eq!(model.objects.len(), 1);
assert_eq!(model.enums.len(), 1);
}

#[test]
fn test_multiple_keyword() {
// Arrange
let path = Path::new("tests/data/model_multiple_keyword.md");

// Act
let model = DataModel::from_markdown(path).expect("Could not parse markdown");

// Assert
assert_eq!(model.objects.len(), 1);
assert_eq!(model.objects[0].attributes.len(), 1);
assert!(model.objects[0].attributes[0].is_array);
}
}

0 comments on commit d688639

Please sign in to comment.