Types
On this page you learn everything you need to know for making useful object references. You can also take a look on Examples for some complex objectReferences and configurations.
Generic TypesCopied!
There are a few generic types that are defined using a string.
{
name: "string",
age: "number",
isCeo: "boolean"
}
ArraysCopied!
You can easily define arrays by specifying them and adding a single item to the array, which represents the array type.
{
favoriteAnimals: ["string"]
}
ObjectsCopied!
It's almost the same as defining an array; you can create objects that contain other types or even nested objects.
{
address: {
street: "string",
floor: "number",
details: {
country: "string"
}
}
}
You can also use objects as types within arrays, allowing for structured and nested data definitions.
{
addresses: [{
street: "string",
floor: "number",
details: {
country: "string"
}
}]
}
EnumsCopied!
You can define enums in your configuration object and reuse them across different endpoints with enum:name. Below is a full configuration example:
{
name: "school-api",
endpoints: [
{
name: "student",
methods: ["GET", "POST", "PATCH", "DELETE"],
objectReference: {
name: "string",
age: "number",
sex: "enum:sex",
subjects: [
name: "string",
grade: "enum:grades"
]
}
}
],
enums: {
sex: ["F", "M"],
grades: ["A", "B", "C", "D", "F"]
}
}
ID ReferenceCopied!
You can reference IDs from different endpoints by using the format id:endpoint_name as a type. This ensures that only valid IDs are passed; otherwise, an error will be thrown.
Below is an extended configuration example based on the enums example:
{
name: "school-api",
endpoints: [
{
name: "student",
methods: ["GET", "POST", "PATCH", "DELETE"],
objectReference: {
name: "string",
age: "number",
sex: "enum:sex",
}
},
{
name: "subject",
methods: ["GET", "POST", "PATCH", "DELETE"],
objectReference: {
name: "string",
studentGrades: [
{
student: "id:student",
grade: "enum:grades"
}
]
}
}
],
enums: {
sex: ["F", "M"],
grades: ["A", "B", "C", "D", "F"]
}
}