Skip to content

jyasskin/schema-org-json-schemas

 
 

Repository files navigation

Schema.org to JSON Schema

Build Status

Generate JSON Schemas from Schema.org classes

You can find the generated schemas in the schemas/ directory.

To match the JSON-LD approach, properties that accept an array also accept a single value.

Example

Schema.org class for a Book

Property Expected Type Description
abridged Boolean Indicates whether the book is an abridged edition.
bookEdition Text The edition of the book.
bookFormat BookFormatType The format of the book.
illustrator Person The illustrator of the book.
isbn Text The ISBN of the book.
numberOfPages Integer The number of pages in the book.

Generated JSON Schema

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "http://schema.org/Book",
  "title": "Book",
  "description": "A book.",
  "type": "object",
  "format": "http://schema.org/Book",
  "allOf": [
    {
      "description": "The most generic kind of creative work, including books, movies, photographs, software programs, etc.",
      "$ref": "CreativeWork.schema.json"
    }
  ],
  "properties": {
    "@context": { "const": "https://schema.org" },
    "@type": { "const": "Book" },
    "bookEdition": {
      "description": "The edition of the book.",
      "type": "string"
    },
    "bookFormat": {
      "description": "The format of the book.",
      "$ref": "BookFormatType.schema.json"
    },
    "illustrator": {
      "description": "The illustrator of the book.",
      "$ref": "Person.schema.json"
    },
    "isbn": { "description": "The ISBN of the book.", "type": "string" },
    "numberOfPages": {
      "description": "The number of pages in the book.",
      "type": "integer"
    }
  },
  "required": ["@type"]
}

To do

Credits

Thanks to geraintluff for the property multiplicity and the hardcoded schemas (licensed under the MIT License).

About

Generate JSON Schemas from Schema.org classes

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%