json Validator Fails when License is included
Opened this issue · 2 comments
Bug report
When including license information in a dataset json file (see the above attached file), the file does not validate.
1. Describe your environment
- OS: NAME, VERSION, 64/32bit MacOS 13.4.1, 64 bit
- pyDataverse: VERSION. 0.3.1
- Python: VERSION python3.9
- Dataverse: VERSION 5.14
2. Actual behaviour:
When reading in a dataset json file ds.from_json(read_file(ds_filename))
(the one attached to this issue), I get the following errors:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/sah/Library/Python/3.9/lib/python/site-packages/pyDataverse/models.py", line 855, in from_json
validate_data(json_dict, filename_schema, file_format="json")
File "/Users/sah/Library/Python/3.9/lib/python/site-packages/pyDataverse/utils.py", line 451, in validate_data
validate(instance=data, schema=read_json(filename_schema))
File "/Users/sah/Library/Python/3.9/lib/python/site-packages/jsonschema/validators.py", line 1302, in validate
raise error
jsonschema.exceptions.ValidationError: {'name': 'CC0 1.0', 'uri': 'http://creativecommons.org/publicdomain/zero/1.0'} is not of type 'string'
Failed validating 'type' in schema['properties']['datasetVersion']['properties']['license']:
{'$id': '#/properties/datasetVersion/properties/license',
'type': 'string'}
On instance['datasetVersion']['license']:
{'name': 'CC0 1.0',
'uri': 'http://creativecommons.org/publicdomain/zero/1.0'}
3. Expected behaviour:
This file does successfully create a dataset with the correct license when using the API via command line (curl). This command works:
curl -H "X-Dataverse-key:$API_TOKEN" -X POST "$SERVER_URL/api/dataverses/$PARENT/datasets" --upload-file dataset-finch1.json -H 'Content-type:application/json
Also discussed here: https://dataverse.zulipchat.com/#narrow/stream/378866-troubleshooting/topic/Validation.20Errors.20Creating.20a.20Dataset.20w.2F.20pyDataverse/near/399798357
Thanks, for opening this issue, Sherry!