schema-jsonld-context

2.0.0 • Public • Published

schema-jsonld-context

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!

install

with npm, do:

npm i --save schema-jsonld-context

example

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"
// }

license

AGPLv3

Package Sidebar

Install

npm i schema-jsonld-context

Weekly Downloads

0

Version

2.0.0

License

AGPLv3

Last publish

Collaborators

  • ahdinosaur