The first step with LDS is to define your JSON Schemas. Here is a simple Person → Address example. Start by creating a SCHEMA_FOLDER directory.
SCHEMA_FOLDER/person.json
{
"$ref": "#/definitions/person",
"definitions": {
"person": { (1)
"type": "object",
"properties": {
"name": { (2)
"type": "string"
},
"addresses": { (3)
"type": "array",
"items": {
"type": "string"
}
},
"_link_property_addresses": { (4)
"type": "object",
"properties": {
"address": { (5)
"type": "null"
}
}
}
}
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
-
person
is an object -
name
is of primitive string type -
addresses
is an array of links to type Address -
_linked_property_addresses
is an instruction to LDS to maintain references to the object `Address`object -
Link property
addresses
toaddress
-object
💡
|
The |
SCHEMA_FOLDER/address.json
{
"$ref": "#/definitions/address",
"definitions": {
"address": { (1)
"type": "object",
"properties": {
"street": { (2)
"type": "string"
},
"city": { (3)
"type": "string"
}
}
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
-
address
is an object -
street
is a property -
city
is a property
curl -X PUT -d {"street": "Doe Street 1", "city": "Cool City"} -i http://localhost:9090/ns/address/1
curl -i http://localhost:9090/ns/person/1
should respond:
{
"name": "John Doe",
"addresses": [
"/address/1"
]
}