SHARE
SHARE copied to clipboard
[quest][wip] stateless metadata rendering
quick lil experiment: use share as a renderer for (potentially private) metadata -- just render on request, don't store anything
all specifics still up in the air
example usage:
import requests
# works for only oai_dc at the moment
url = 'http://localhost:8000/api/v2/pls-render-metadata?metadata_formats=oai_dc'
request_body = [
{'@id': '_:a', '@type': 'creativework', 'title': 'foo'},
{
'@id': '_:b',
'@type': 'workidentifier',
'creative_work': {'@id': '_:a', '@type': 'creativework'},
'uri': 'http://example.com/foo',
},
]
response = requests.post(url, json.dumps(request_body))
assert response.json() == ['<oai_dc:dc xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd"><dc:title>foo</dc:title><dc:type>creativework</dc:type><dc:identifier>http://example.com/foo</dc:identifier></oai_dc:dc>']