Sample data#
A sample document answers for a service, so that an app that reads from one can run without it. The host's scripted providers return the sample's answers as if the service had given them. The definition does not change: the same file runs against the real service when the host connects one.
The shape#
JSON
{
"weather": {
"get": {
"status": 200,
"headers": { "content-type": "application/json" },
"body": {
"city": "Lisbon",
"now": 18,
"days": [
{ "date": "2026-11-13", "high": 19, "low": 12, "summary": "Sunny" },
{ "date": "2026-11-14", "high": 17, "low": 11, "summary": "Showers" },
{ "date": "2026-11-15", "high": 16, "low": 10, "summary": "Cloudy" }
]
}
}
}
}
- Each top-level key is a capability alias of the definition, here
weather. - Under it, each key is an operation of that capability's contract, here
get. - The value is the operation's output, exactly as the contract types it: a
core:httpgetreturns acore:HttpResponsewithstatus,headersandbody. Every call returns a copy of the same value, whatever its input. - An operation with no answer in the sample fails when it is called, with a message that names the alias and the operation. Give an answer for every operation the app calls on that capability.
Run the app with it:
oad run weather.oad.json --sample weather.sample.json
A look at the app, and oad run without --sample, read a sample-data.json beside the definition when there is one. When an answer does not fit the operation's output type, the host warns as the app starts, naming the path in the sample.
Which capabilities need one#
Write sample answers for capabilities that reach a service: core:http and contracts from other catalogs. A core capability the sample does not name is served by the host's own implementation: notifications, the schedule, records, files and the device capabilities work on the reference host without a sample. A core:http capability the sample does not name reaches the real address in its origin.
Records a service already holds#
A core:records capability that reads records kept elsewhere, such as tickets in a help desk, starts with an empty collection on the host. Give the records instead of answers, under $records:
JSON
{
"helpdesk": {
"$records": [
{ "id": "T-1", "subject": "Printer jams", "priority": "high", "status": "open" },
{ "id": "T-2", "subject": "Refund not received", "priority": "low", "status": "pending" }
]
}
}
The host's records provider then answers every operation from them: filters, sorting, paging, counts and aggregates follow what the app asks, what it writes is kept, and its first screen is not empty. A fixed answer for list gives the same page whatever the filter, the order or the cursor. The records are for everyone, never under $person, and the alias holds nothing beside them.
People in a directory#
A core:directory capability gives its people under $people, each with their manager's id: { "people": { "$people": [{ "id": "u-1", "name": "Ana Silva", "manager": "u-2" }, { "id": "u-2", "name": "Mara Lind" }] } }. The host's directory answers from them.
Writing good answers#
- Make the answer look like the real service. The app's expressions read the answer's fields (
state.forecast.body.daysabove), so name the fields as the service does. - Keep dates current. Give
"$asOf": "2026-11-13"at the top level: the day your dates were written for. The host moves each value its type declares adateordatetimeby whole weeks to today, so weekdays and gaps stay. A date in text or in an untyped value, such as the weatherbodyabove, is not moved: pick dates the app copes with. - Answers per person. Under the top-level key
$person, each key is a person's id and holds answers for that person only, in the same shape as the whole document. Everyone else gets the answers at the top level. - Errors. A sample cannot make a call fail; an app's error handling is tried by leaving the operation out of the sample, which makes its calls fail.
What a sample does not do#
Outside $records, it does not deliver capability events, and it does not remember what the app wrote: a write operation returns its sample answer and changes nothing that a later read returns. Records under $records keep each write and announce it as a record changing.
Next#
capabilitiesfor the operations and their output types.statefor sourced entries that read them.startfor how to work: write, check, look, change.