inveniosoftware / datacite

Python API wrapper for the DataCite API.
https://datacite.readthedocs.io
Other
27 stars 33 forks source link

Schema from example not validating #70

Closed mcrot closed 2 years ago

mcrot commented 2 years ago

Package version (if known): 1.1.2

Describe the bug

The example in the documentation starts with

from datacite import DataCiteMDSClient, schema42

data = {
    'identifier': {
        'identifierType': 'DOI',
        'identifier': '10.1234/foo.bar',
    },
    'creators': [
        {'name': 'Smith, John'},
    ],
    'titles': [
        {'title': 'Minimal Test Case', }
    ],
    'publisher': 'Invenio Software',
    'publicationYear': '2015',
    'types': {
        'resourceType': 'Dataset',
        'resourceTypeGeneral': 'Dataset'
    },
    'schemaVersion': 'http://datacite.org/schema/kernel-4',
}

# Validate dictionary
assert schema42.validate(data)

This assertion fails.

Steps to Reproduce

  1. Install datacite from pypi.
  2. Copy the code above into a file editor.
  3. Run the file
  4. The assertion fails:
$ python datacite-example.py 
Traceback (most recent call last):
  File "datacite-example.py", line 24, in <module>
    assert schema42.validate(data)
AssertionError

Expected behavior

schema42.validate(data) should be True.

tmorrell commented 2 years ago

I apologize for the stale documentation. We have an issue with readthedocs not updating #65, which I'll try to resolve. The working example is available at https://github.com/inveniosoftware/datacite/blob/master/tests/example/full.py; the difference is that the 4.2 schema uses 'identifiers' as the label instead of 'identifier'

tmorrell commented 2 years ago

I've created an updated version of the documentation at https://datacite-test.readthedocs.io/en/latest/ and have swapped it in. This should work until we figure out the issue with the old readthedocs link.