CenterForOpenScience / SHARE

SHARE is building a free, open, data set about research and scholarly activities across their life cycle.
http://share-research.readthedocs.io/en/latest/index.html
Apache License 2.0
100 stars 58 forks source link

[quest][wip] stateless metadata rendering #790

Open aaxelb opened 2 years ago

aaxelb commented 2 years ago

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>']
coveralls commented 2 years ago

Coverage Status

Coverage decreased (-0.03%) to 84.333% when pulling 2070b57ef76523dfdce5c1749da5a7bc584f095b on aaxelb:quest/stateless-metadata-render into c7715af2881f6fa23197d4e7c381d90169a90ed1 on CenterForOpenScience:develop.