- jsonschema - pyyaml - requests - typing_extensions - paths: - oasld.py

REST API Linked Data keywords

Edit the Person schema on the left editor panel. You can reference other schemas Provide the x-jsonld-type and x-jsonld-context keywords and include an `example` entry. When you click on the blue button, the entry will be annotated with the JSON-LD type and context.
Learn more on the GitHub repository.

          click on the blue button to generate yaml-ld from json.
        
        click on the blue button to generate yaml-ld from json.
        
import logging log = logging.getLogger() import yaml import json from oasld import RefResolver, Instance, process_schema, sample_schema from pyodide import create_proxy from urllib.parse import quote_plus def on_apply(event): global code, button text = code.value schemas = yaml.safe_load(text) instance = process_schema("Person", schemas) json_ld = json.dumps(instance.ld, indent=2) Element("json-ld-output").write(json_ld) Element("yaml-ld-output").write(yaml.safe_dump(instance.ld)) href = document.getElementById("playground-ref") href.setAttribute("href", "https://json-ld.org/playground/?json-ld=%s" % quote_plus(json_ld)) code = Element("code") button = document.querySelector("button") button.addEventListener("click", create_proxy(on_apply)) if len(code.value) < 100: code.write(yaml.safe_dump(sample_schema))