Skip to content

Commit

Permalink
CSL JSON: date-parts set minItems to 1
Browse files Browse the repository at this point in the history
Currently, the JSON Schema allows empty arrays in date-parts, which
can cause downstream citeproc utilities to crash. See
manubot/manubot#66

Set minItems to 1 for the date-parts array as well as the nested
arrays with year, month, day info.
  • Loading branch information
dhimmel committed May 21, 2020
1 parent 7179185 commit 6bbb80b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions csl-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,10 @@
"number"
]
},
"minItems": 1,
"maxItems": 3
},
"minItems": 1,
"maxItems": 2
},
"season": {
Expand Down
15 changes: 15 additions & 0 deletions tests/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,18 @@ def test_data_schema_with_extra_property_fails(csl_data_validator):
}]
with pytest.raises(jsonschema.exceptions.ValidationError):
csl_data_validator.validate(csl)

def test_data_schema_with_empty_date_parts(csl_data_validator):
"""
empty arrays in date-parts can cause downstream citeproc failures
https://github.com/citation-style-language/schema/pull/158
"""
csl = [{
'id': 'example-id',
'type': 'report',
'issued': {
"date-parts": []
},
}]
with pytest.raises(jsonschema.exceptions.ValidationError):
csl_data_validator.validate(csl)

0 comments on commit 6bbb80b

Please sign in to comment.