Skip to content

A bunch of JSON Schema specifications of general interest you can freely $ref.

License

Notifications You must be signed in to change notification settings

jenkin/json-schema-bricks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON Schema Bricks

A bunch of JSON Schema specifications of general interest you can freely $ref.

Getting started

JSON Schema specification allows schemas composition and cross-reference using $ref attribute.

This project lists some useful reusable schemas ready to be referenced by yours. The dev variants are human-readable and can contain external references (resolved at runtime), in the prod ones all external schemas are dereferenced (so resolved at build time) and included in a standalone minified bundle. You can also refer to a sub-schema using JSON pointers (see the second example).

Tip! Take also a look to JSON Schema Store, it freely lists and serves hundreds of open source schemas!

Example

A (partial) validation of the Node Package Manager package.json (see the official docs).

{
  "title": "A node project",
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "version": {
      "$ref": "https://jenkin.dev/json-schema-bricks/semver.schema.min.json"
    }
    "description": {
      "type": "string"
    },
    "keywords": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "homepage": {
      "type": "string",
      "format": "uri"
    }
  }
}

Validation of an object that represents an image.

{
  "title": "An image",
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "size": {
      "description": "File size in bytes",
      "type": "integer",
      "minimum": 0
    },
    "width": {
      "description": "Image width in pixels",
      "type": "integer",
      "minimum": 0
    },
    "height": {
      "description": "Image height in pixels",
      "type": "integer",
      "minimum": 0
    },
    "type": {
      "description": "An official mime-type",
      "$ref": "https://jenkin.dev/json-schema-bricks/IANAMediaTypes.schema.min.json#/$defs/ImageRegistry"
    }
  }
}

Table of Contents

IANA Internet Assigned Numbers Authority

IANA (Internet Assigned Numbers Authority) allocates and maintains unique codes and numbering systems that are used in the technical standards (protocols) that drive the Internet.

Protocol parameter registries represent the authoritative record of many of the codes and numbers contained in a variety of Internet protocols. IANA maintains these records in compliance with the associated technical standards and allocation policies, and provides this service in coordination with the Internet Engineering Task Force (IETF).

IANA Language Subtag Registry

IANA Language Subtag schema [prod, dev].

This document describes the structure, content, construction, and semantics of language tags for use in cases where it is desirable to indicate the language used in an information object. It also describes how to register values for use in language tags and the creation of user-defined extensions for private interchange.

Source: https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry (see RFC5646).

Notes: only Subtags with Type: language are listed.

IANA Link Relation Types Registry

IANA Link Relation Types schema [prod, dev].

This specification defines a model for the relationships between resources on the Web (links) and the type of those relationships (link relation types).

Source: https://www.iana.org/assignments/link-relations/link-relations.xhtml (see RFC8288).

IANA Media Types Registries

IANA Media Types schema [prod, dev].

This specification defines a model for the relationships between resources on the Web (links) and the type of those relationships (link relation types).

Source: https://www.iana.org/assignments/media-types/media-types.xhtml (see RFC6838 and RFC4855).

Registries:

Templates (custom regex):

Combinations:

Notes: empty, obsolete or deprecated media types are excluded, text/plain is included. Root schema references AllRegistries.

IANA Character Sets Registries

IANA Character Sets schema [prod, dev].

These are the official names for character sets that may be used in the Internet and may be referred to in Internet documentation.

Source: https://www.iana.org/assignments/character-sets/character-sets.xhtml (see RFC2978).

Registries:

Combinations:

  • all registries but MIBenum [prod, dev]

Notes: MIBenum has string type. Root schema references AllRegistries.

ISO International Organization for Standardization

ISO (International Organization for Standardization) is an independent, non-governmental international organization with a membership of 169 national standards bodies.

ISO 3166 is the International Standard for country codes and codes for their subdivisions. Its purpose is to define internationally recognized codes of letters and/or numbers that we can use when we refer to countries and their subdivisions. It has three parts: codes for countries (ISO 3166-1), codes for subdivisions (ISO 3166-2) and formerly used codes (ISO 3166-3, codes that were once used to describe countries but are no longer in use).

ISO 3166-1

ISO 3166-1:2020 schema [prod, dev].

Codes for the representation of names of countries and their subdivisions - Part 1: Country code

Source: https://www.iso.org/standard/72482.html (see also the glossary).

Registries:

Templates (custom regex):

Combinations:

  • all registries (only for codes, English short names are excluded) [prod, dev]
  • all templates (only for codes, English short names are excluded) [prod, dev]

ISO 3166-2

ISO 3166-2:2020 schema [prod, dev].

Codes for the representation of names of countries and their subdivisions - Part 2: Country subdivision code

Source: https://www.iso.org/standard/72483.html (see also the glossary).

Registries:

  • single country subdivision codes, one per ISO 3166-1 country code in the form [A-Z]Registry (ie. ITRegistry for Italy [prod, dev]).
  • single country subdivision English short names, one per ISO 3166-1 country code in the form [A-Z]EnglishShortNames (ie. ITEnglishShortNames for Italy [prod, dev]).

Templates:

  • single country subdivision templates, one per ISO 3166-1 country code in the form [A-Z]Template (ie. ITTemplate for Italy [prod, dev]).

Combinations:

  • all registries (only for codes, English short names are excluded) [prod, dev]
  • all templates (only for codes, English short names are excluded) [prod, dev]
  • all English short names [prod, dev]

Notes: codes are based on the two-letter code element from ISO 3166-1 followed by a separator and up to three alphanumeric characters.

ISO 3166-3

ISO 3166-3:2020 schema [prod, dev].

Codes for the representation of names of countries and their subdivisions - Part 3: Code for formerly used names of countries

Source: https://www.iso.org/standard/72484.html (see also the glossary).

Registries:

Templates (custom regex):

Geographic Information System (GIS)

A geographic information system (GIS) consists of integrated computer hardware and software that store, manage, analyze, edit, output, and visualize geographic data.

GeocodeJSON

OFFICIALLY ADOPTED!!!

Official GeocodeJSON schema [prod, dev].

An attempt to have standard geojson responses from geocoders.

Source: https://github.com/geocoders/geocodejson-spec (see geocodejson-spec/pull/25).

GeoHash

GeoHash [prod, dev].

Geohash is a public domain geocode system which encodes a geographic location into a short string of letters and digits.

Source: http://geohash.org

Miscellaneous

JSON Hypertext Application Language

HAL+JSON [prod, dev].

This document proposes a media type for representing resources and their relations with hyperlinks.

Source: https://github.com/mikekelly/hal-rfc (see hal-rfc/issues/28).

Semantic Versioning

SemVer [prod, dev].

Under this scheme, version numbers and the way they change convey meaning about the underlying code and what has been modified from one version to the next.

Source: https://semver.org (see semver.org/issues/431).

Contributing

Any contribution is welcome! Please read and accept our Code of Conduct, then refer to Contributing Guidelines before opening issues or pull requests.

Please use json-dereference-cli to build minified variants (you need nodejs and npm): npx -y [email protected] -s docs/NAME.schema.json -o docs/NAME.schema.min.json.

License

CC0 1.0 Universal

About

A bunch of JSON Schema specifications of general interest you can freely $ref.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks