Ditto is a cli tool to mock an API or a kafka producer.
Supported fields:
INTEGER:VALUE: hardcoded valueINCREMENTAL: from aSTARTvalue, increase by a fixedSTEP- NOTE: An optional
SIGMAcan be passed to make the delta follow a normal distribution around theSTEP
- NOTE: An optional
DISTRIBUTION:NORMAL: returns a value for a givenMUandSIGMAUNIFORM: returns a value between aMIXandMAXRANDOM: returns a random integer, optionally limited by aMAXvalue
FLOAT:VALUE: hardcoded valueINCREMENTAL: from aSTARTvalue, increase by a fixedSTEP- NOTE: An optional
SIGMAcan be passed to make the delta follow a normal distribution around theSTEP
- NOTE: An optional
DISTRIBUTION:NORMAL: returns a value for a givenMUandSIGMAUNIFORM: returns a value between aMIXandMAXRANDOM: returns a random float between (0,1], optionally multiplied by aSCALEvalue
- Additional Params:
ROUND: Number of decimal values. Defaults to 2
STRING:VALUE: hardcoded valueREGEX: regex template to generate a random string- Additional Params:
EMPTY: Probability ((0, 1]) of the string being empty. Defaults to 0
TIMESTAMP:VALUE: hardcoded valueNOW: current timestampINCREMENTAL: from aSTARTvalue, increase by a fixedSTEP. The start value defaults toNOW- NOTE: An optional
SIGMAcan be passed to make the delta follow a normal distribution around theSTEP - NOTE: The step should follow the format "\d+[hms]"
- NOTE: An optional
- Additional Params:
PRECISION: Units of the timestamp. Supported values are "s" (default), "ms", "us", "ns"
DATETIME:VALUE: hardcoded valueNOW: current timestampINCREMENTAL: from aSTARTvalue, increase by a fixedSTEP. The start value defaults toNOW- NOTE:
STEPshould follow the format "\d+[hms]" - NOTE:
STARTshould be a unix timestamp - NOTE: An optional
SIGMAcan be passed to make the delta follow a normal distribution around theSTEP
- NOTE:
- Additional Params:
FORMAT: Format of the datetime string (using the go reference date)
OBJECT:FIELDS: Array with the nested fields
Additionally, there are certain parameters common between all types:
NULLABLE: Probability ((0, 1]) of the value being null. Defaults to 0REPEATED: Whether the value is an array. It will create an array between 0 and 10 elements.
To serve message as an rest api:
ditto server rest -s schema.json -p 8080If the schema is a folder, it will create a unique endpoint for each schema present using the name of the file as the url.
To send messages to kafka (requires a running Kafka cluster):
ditto producer kafka -s schema.json -b localhost:9092 -S 3 [-c 2] [-d sample]If the schema is a folder, it will send messages to a topic that matches the name of the file. If the -t flag is passed, it will send all messages to that topic.
- Cli command to generate schema from json
- Consume messages and verify that they follow the defined schema
- Add error support (random error codes, wrong types,...)
- Support other file formats
- Return arrays
- Tests
- Support other outputs (GraphQL,...)