returns a jsonld @context
from a json-schema with prefixes
and context
properties.
supports
- properties
- additionalProperties
- patternProperties
- allOf
- anyOf
- oneOf
- not
- definitions
- items schema
- items array of schemas
- additionalItems
pull requests welcome!
with npm, do:
npm i --save schema-jsonld-context
var schemaJsonldContext = require('schema-jsonld-context');
var personSchema = {
id: "http://example.org/schemas/Person.json#",
prefixes: {
"": "http://schema.org/",
"foaf": "http://xmlns.com/foaf/0.1/",
},
context: "foaf:Person",
properties: {
name: {
context: "name",
type: "string",
},
nick: {
context: "foaf:nick",
type: "string",
},
},
};
var personContext = schemaJsonldContext(personSchema);
console.log(JSON.stringify(personContext, null, 2));
// {
// "@vocab": "http://schema.org/",
// "foaf": "http://xmlns.com/foaf/0.1/",
// "Person": "foaf:Person",
// "nick": "foaf:nick"
// }
AGPLv3