string
Synth's string
generator type regroups many different useful functionalities, including the ability to generate
sentences from regular expressions, as well as leveraging Faker providers to generate valid addresses,
telephone numbers, etc.
#
patternString values generated by a specified regular expression in the pattern
key.
#
Example{ "type": "string", "pattern": "I am a (man|woman) with [2-9] friends"}
#
uuiduuid
generates hyphenated UUIDs.
This generator has no parameters.
#
Example{ "type": "string", "uuid": {}}
#
formatformat
allows to format one or more string values by parsing a parametric
format string and processing the specified replacements.
#
Example{ "type": "string", "format": { "format": "my name is {name} and my email is {email}", "arguments": { "name": { "type": "string", "faker": { "generator": "username" } }, "email": { "type": "string", "faker": { "generator": "safe_email" } } } }}
#
fakerSynth has an internal fake data generator that will generate fake data for semantic types such as Names, Addresses, etc.
#
Example{ "type": "string", "faker": { "generator": "address" }}
Faker offers a variety of different fake data, in different locales and can be leveraged easily from Synth schemas using
the generator
key.
#
first_name{ "type": "string", "faker": { "generator": "first_name" }}
#
last_name{ "type": "string", "faker": { "generator": "last_name" }}
#
title{ "type": "string", "faker": { "generator": "title" }}
#
suffix{ "type": "string", "faker": { "generator": "suffix" }}
#
name{ "type": "string", "faker": { "generator": "name" }}
#
name_with_title{ "type": "string", "faker": { "generator": "name_with_title" }}
#
credit_card{ "type": "string", "faker": { "generator": "credit_card" }}
#
free_email_provider{ "type": "string", "faker": { "generator": "free_email_provider" }}
#
domain_suffix{ "type": "string", "faker": { "generator": "domain_suffix" }}
#
free_email{ "type": "string", "faker": { "generator": "free_email" }}
#
safe_email{ "type": "string", "faker": { "generator": "safe_email" }}
#
username{ "type": "string", "faker": { "generator": "username" }}
#
ipv4{ "type": "string", "faker": { "generator": "ipv4" }}
#
ipv6{ "type": "string", "faker": { "generator": "ipv6" }}
#
ip{ "type": "string", "faker": { "generator": "ip" }}
#
mac_address{ "type": "string", "faker": { "generator": "mac_address" }}
#
color{ "type": "string", "faker": { "generator": "color" }}
#
user_agent{ "type": "string", "faker": { "generator": "user_agent" }}
#
rfc_status_code{ "type": "string", "faker": { "generator": "rfc_status_code" }}
#
valid_status_code{ "type": "string", "faker": { "generator": "valid_status_code" }}
#
company_suffix{ "type": "string", "faker": { "generator": "company_suffix" }}
#
company_name{ "type": "string", "faker": { "generator": "company_name" }}
#
buzzword{ "type": "string", "faker": { "generator": "buzzword" }}
#
buzzword_muddle{ "type": "string", "faker": { "generator": "buzzword_muddle" }}
#
buzzword_tail{ "type": "string", "faker": { "generator": "buzzword_tail" }}
#
catch_phrase{ "type": "string", "faker": { "generator": "catch_phrase" }}
#
bs_verb{ "type": "string", "faker": { "generator": "bs_verb" }}
#
bs_adj{ "type": "string", "faker": { "generator": "bs_adj" }}
#
bs_noun{ "type": "string", "faker": { "generator": "bs_noun" }}
#
bs{ "type": "string", "faker": { "generator": "bs" }}
#
profession{ "type": "string", "faker": { "generator": "profession" }}
#
industry{ "type": "string", "faker": { "generator": "industry" }}
#
city_prefix{ "type": "string", "faker": { "generator": "city_prefix" }}
#
city_suffix{ "type": "string", "faker": { "generator": "city_suffix" }}
#
city_name{ "type": "string", "faker": { "generator": "city_name" }}
#
country_name{ "type": "string", "faker": { "generator": "country_name" }}
#
country_code{ "type": "string", "faker": { "generator": "country_code" }}
#
street_suffix{ "type": "string", "faker": { "generator": "street_suffix" }}
#
street_name{ "type": "string", "faker": { "generator": "street_name" }}
#
time_zone{ "type": "string", "faker": { "generator": "time_zone" }}
#
state_name{ "type": "string", "faker": { "generator": "state_name" }}
#
state_abbr{ "type": "string", "faker": { "generator": "state_abbr" }}
#
secondary_address_type{ "type": "string", "faker": { "generator": "secondary_address_type" }}
#
secondary_address{ "type": "string", "faker": { "generator": "secondary_address" }}
#
zip_code{ "type": "string", "faker": { "generator": "zip_code" }}
#
post_code{ "type": "string", "faker": { "generator": "post_code" }}
#
building_number{ "type": "string", "faker": { "generator": "building_number" }}
#
latitude{ "type": "string", "faker": { "generator": "latitude" }}
#
longitude{ "type": "string", "faker": { "generator": "longitude" }}
#
phone_number{ "type": "string", "faker": { "generator": "phone_number" }}
#
cell_number{ "type": "string", "faker": { "generator": "cell_number" }}
#
file_path{ "type": "string", "faker": { "generator": "file_path" }}
#
file_name{ "type": "string", "faker": { "generator": "file_name" }}
#
file_extension{ "type": "string", "faker": { "generator": "file_extension" }}
#
dir_path{ "type": "string", "faker": { "generator": "dir_path" }}
#
serializedserialized
is a variant of the string
generator type which serializes the output of a child generator into a string.
serialized
has 2 fields,
serializer
: The serializer to be used (currently onlyjson
)content
: The content to be serialized. This can be any valid Synth generator
#
Example{ "type": "string", "serialized": { "serializer": "json", "content": { "type": "object", "username": { "type": "string", "faker": { "generator": "name" } } } }}
#
truncatedThe truncated
generator truncates the output of it's inner generator to a fixed length.
If the output of its inner generator is less than or equal to the length, it is left untouched.
truncated
has 2 fields,
length
: The number of characters to truncate to. This can be any Synth generator that yields a non-negative Number.content
: The content to be truncated. This can be any Synth generator that yields a String.
#
Example{ "type": "string", "truncated": { "content": { "type": "string", "pattern": "[a-zA-Z0-9]{0, 255}" }, "length": 5 }}
#
slicedThe sliced
generator takes a character slice of a string.
The slice format is [start]:[finish]
and if it fails to parse the original string will be returned.
sliced
has 2 fields,
slice
: A string with a optional start and optional end separated by:
content
: The content to be sliced. This can be any Synth generator that yields a String.
#
Example{ "type": "string", "sliced": { "content": { "type": "string", "pattern": "[a-zA-Z0-9]{10, 20}" }, "slice": "3:5" }}
#
constantThe constant
generator allows you to generate a constant string. Strings that begin with @
can
also be declared constant instead of being treated as a reference, although you need to use the long-form version:
{ "type": "string", "constant": "@foobar"}
Or shorthand notation if you are declaring an object field:
{ "type": "object", "name": "bob"}
#
categoricalA categorical
is a variant of the string
generator type that generates values from a finite set of user-defined
values. You can specify a string as a categorical by using the "categorical": {...}
key/value pair.
#
Example{ "type": "string", "categorical": { "pawn": 8, "rook": 2, "knight": 2, "bishop": 2, "queen": 1, "king": 1 }}
The value of the "categorical"
key must be an object whose:
- keys are the allowed values of the categorical (e.g.
"pawn"
,"rook"
, etc.), - values are non-negative integers defining the relative weight of the corresponding variant (e.g.
8
,2
, etc.).