Skip to content

holodex/schema-jsonld-context

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published