Stream
A stream defines the schema and content of an unbounded sequence of JSON values. They are used by entities to simulate a dataset.
Consider the following stream 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 stream 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 stream types are composable - some "higher level" stream types accept other stream definitons as parameters
In the above example, we specify streams in the variables
parameter of the function
stream defintion which is itself specified as part of the properties
parameter of the top-levelobject
stream definition.
See Types for details.
Types
Stream types are organized under namespaces. You can reference one either by its fully-qualified name (e.g schema.object
) or by its simple name (e.g. object
)
schema
The rngo stream definition language is a superset of JSON Schema, meaning that JSON Schema can be used to define a stream.
These stream types correspond to a JSON Schema type and expect the same fields as their JSON Schema equivalent (or a subset thereof during the rngo beta)
- schema.object
- schema.array
- schema.string
- schema.integer
- schema.number
- schema.boolean
- schema.null
- schema.enum
- schema.const
core
Primitives used to build other, higher-level types.
id
Different types of identifiers.
person
Data associated with humans.