Skip to content

Commit

Permalink
fix missing type
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-1991 committed Dec 12, 2024
1 parent a8ebda4 commit 55e9036
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/json/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ impl TryFrom<&Attribute> for schema::Property {
let description = (!attr.docstring.is_empty()).then(|| attr.docstring.clone());
let enum_values = if attr.is_enum { Some(Vec::new()) } else { None };

if attr.dtypes.len() > 1 {
if attr.dtypes.len() > 1 && !attr.is_array {
// If there are multiple types, we need to use the AnyOf case
dtype = None;
}
Expand Down Expand Up @@ -489,7 +489,7 @@ mod tests {

let expected_json = json!({
"title": "test_attribute",
"anyOf": [
"oneOf": [
{"type": "string"},
{"$ref": "#/$defs/RefType"},
]
Expand Down Expand Up @@ -523,7 +523,7 @@ mod tests {
"title": "test_attribute",
"type": "array",
"items": {
"anyOf": [
"oneOf": [
{"type": "string"},
{"$ref": "#/$defs/RefType"}
]
Expand Down
1 change: 1 addition & 0 deletions tests/data/expected_json_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
},
"multiple_types_array": {
"title": "multiple_types_array",
"type": "array",
"items": {
"oneOf": [
{
Expand Down

0 comments on commit 55e9036

Please sign in to comment.