Schema

A schema defines the structure and content of an unbounded sequence of JSON values. They are used by entities to simulate a dataset.

Consider the following schema definition:

type: object
properties:
  email:
    type: function
    expression: username + '@' + domain
    variables:
      username:
        type: string
        maxLength: 10
      domain:
        type: enum
        enum:
          - example.com
          - example.org
  age:
    type: integer
    minimum: 0
    maximum: 120

It will endlessly produce values that look like this:

{ "email": "kjandfa@example.com", "age": 16 }
{ "email": "9jsm348vk@example.org", "age": 77 }
{ "email": "111//??@example.org", "age": 58 }

The first thing to note is that every schema definition must specify a type field, which acts as a discriminant - i.e., it determines the other fields that may be specified in the definition.

In the above example, the top-level definition has type object, which requires aproperties parameter while theage property has typeinteger, which accepts optionalminimum andmaximum parameters.

The second thing to note is that schema types are composable - some "higher level" schema types accept other schema definitons as parameters

In the above example, we specify schemas in the variables parameter of the function schema defintion which is itself specified as part of the properties parameter of the top-levelobject schema definition.

See the schema reference for all available schemas.