Reference
JSON Schema
rngo aims to support all keywords in the 2020-12 draft of JSON Schema that are applicable to data generation, but for now, only a subset are supported.
See the Streams reference and the tutorial for how JSON Schema is used to define a simulation.
Custom Vocabulary
rngo extends JSON Schema with a custom vocabulary to support the generation of realistic data. All extension keywords are nested under the rngo
keyword and do not change the validation semantics of the schema.
rngo.value
The rngo.value
keyword specifies an expression that returns either a Set
or a single Value
. For example:
type: object
properties:
name:
type: string
rngo:
value: data.person.fullName
In this case, a value will be randomly selected from the data.person.fullName
set when generating a value for the name
property.
Upon stream creation or update, rngo will validate that all rngo.value
expressions returns a value or set of the correct type.
See Expressions for more information.
rngo.probability.type
When a schema has multiple type references, you can specify the probability that each type will be generated with the rngo.probability.type
keyword.
The most common scenario for this is to make a value nullable:
type:
- integer
- null
rngo:
probability:
type:
integer: 4
null: 1
The keyword expects a map from the type name to a weight. So, the above defines a schema that produces an integer 80% of the time and null
20% of the time.
Weights must be positive integers. By default, each type has a weight of 1
.
rngo.probability.properties
For object schemas, you can specify that a likelihood that a non-required property will be included in the generated value via the rngo.probability.properties
keyword:
type: object
properties:
id:
type: integer
name:
type: string
homepage:
type: string
required:
- id
rngo:
probability:
properties:
name: 0.9
homepage: 0.5
The keyword expects a map from a property name to a probability between 0 and 1. So, the above schema will produce an object with a name
property 90% of the time and a homepage
property 50% of the time.
By default, a non-required property has a 60% chance of being included. A required property may not be referenced by rngo.probability.properties
.
format
Keyword
rngo supports the format
keyword for string schemas, including all built-in formats from the JSON Scheme specification (eventually), along with many custom options.
Date / Time
Key | Description | Example |
date | RFC 3339 date | "2024-11-13" |
date-time | RFC 3339 date and time together | "2024-11-13T20:20:39+00:00" |
time | RFC 3339 time string | "20:20:39+00:00" |
IDs
Key | Description | Example |
cuid | Secure, colision-resistant ID | "el81eslmbh0u6kkav308v2r2j" |
uuid | RFC 4122 universally unqiue identifier | "c116b452-3449-4e1d-88ac-ef007a08d92f" |
Internet
Key | Description | Example |
email | RFC 5321 email address | "alice@example.com" |