rngo

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

KeyDescriptionExample
dateRFC 3339 date"2024-11-13"
date-timeRFC 3339 date and time together"2024-11-13T20:20:39+00:00"
timeRFC 3339 time string"20:20:39+00:00"

IDs

KeyDescriptionExample
cuidSecure, colision-resistant ID"el81eslmbh0u6kkav308v2r2j"
uuidRFC 4122 universally unqiue identifier"c116b452-3449-4e1d-88ac-ef007a08d92f"

Internet

KeyDescriptionExample
emailRFC 5321 email address"alice@example.com"

Keyword Support

KeywordVocabularySupport
additionalPropertiesapplicator [object]planned
allOfapplicatorplanned
$anchorcorenot planned
anyOfapplicatorplanned
$commentcorenot planned
constvalidationplanned
containsapplicator [array]planned
contentEncodingcontent [string]planned
contentMediaTypecontent [string]planned
contentSchemacontent [string]planned
defaultmeta datanot planned
$defscorenot planned
dependentSchemaapplicator [object]planned
deprecatedmeta dataplanned
descriptionmeta datanot planned
$dynamicAnchorcorenot planned
$dynamicRefcorenot planned
enumvalidationfull
examplesmeta datanot planned
exclusiveMaximumvalidation [number]planned
exclusiveMinimumvalidation [number]planned
formatformat assertion [string]partial
$idcorenot planned
if / then / elseapplicatorplanned
itemsapplicator [array]full
maxContainsvalidation [array]planned
maximumvalidation [number]full
maxItemsvalidation [array]full
maxLengthvalidation [string]full
maxPropertiesvalidation [object]planned
minContainsvalidation [array]planned
minimumvalidation [number]full
minItemsvalidation [array]full
minLengthvalidation [string]full
minPropertiesvalidation [object]planned
multipleOfvalidation [number]planned
notapplicatorplanned
oneOfapplicatorplanned
patternvalidation [string]planned
patternPropertiesapplicator [object]planned
prefixItemsapplicator [array]planned
propertiesapplicator [object]full
propertyNamesapplicator [object]planned
readOnlymeta datanot planned
$refcorenot planned
requiredvalidation [object]full
$schemacorenot planned
titlemeta datanot planned
typevalidationfull
unevaluatedItemsunevaluated [array]planned
unevaluatedPropertiesunevaluated [object]planned
uniqueItemsvalidation [array]planned
$vocabularycorenot planned
writeOnlymeta datanot planned
Previous
Expressions