Update 3 Objects, Enums, and Colors
We're back with another update! This time, we're introducing some of the most requested features to Mockd: custom objects, object arrays, enums, and color support.
๐๏ธ Custom Objects (object)โ
You can now define your own custom types using the types field in your request. This is perfect for when you need a specific structure for your data.
How to use it:โ
- Define your custom structure in the
typesobject. - Reference your custom type in the
fieldsobject usingobject-[typeName].
{
"types": {
"User": {
"id": "uuidv4",
"name": "male-full-name",
"email": "email"
}
},
"fields": {
"admin": "object-[User]"
}
}
๐๏ธ Object Arrays (object-array)โ
Need a list of those custom objects? object-array has you covered. It works just like the array type but for your custom defined types.
How to use it:โ
Reference your custom type using object-array-[typeName(size)].
{
"types": {
"Product": {
"sku": "mask-[AAA-####]",
"price": "money"
}
},
"fields": {
"inventory": "object-array-[Product(3)]"
}
}
๐ข Enums (enum)โ
The enum type allows you to provide a list of specific values, and Mockd will randomly select one for you.
How to use it:โ
Provide a comma-separated list of values inside square brackets: enum-[value1,value2,value3].
{
"fields": {
"status": "enum-[pending,active,completed,cancelled]"
}
}
๐จ Color (color-hex)โ
Adding some visual flair to your mocks? The color-hex type generates a random hexadecimal color string.
How to use it:โ
Simply use color-hex as the field type.
{
"fields": {
"primaryColor": "color-hex"
}
}
We hope these new types help you build even better things with Mockd! As always, if you have any feedback or feature requests, feel free to reach out.
