Added some examples

Nick Winter 2013-12-26 11:15:55 -08:00
parent 1158de9b79
commit a95f95f751

@ -9,3 +9,66 @@ Probably one of the least known tools in our kit, but also one of the most centr
* __Definition__. There is a universal place for data to be defined, which can be used by you, the Archmages, to see how a given document ought to be structured, and in the future for potential API clients to tap into our existing data structures.
It's important if you are working with data in any way on CodeCombat to understand how JSON-Schema relates to your work. Change to a schema affect every layer of the software stack. Look for further opportunities to use it to automate complex but repeated processes.
## Why It's Awesome With [Treema](https://github.com/codecombat/treema)
The schema returned by [http://codecombat.com/db/level_component/schema](http://codecombat.com/db/level_component/schema) is too long to include here, but basically it lets us generate a UI like this:
![Treema for the LevelComponent schema](https://dl.dropboxusercontent.com/u/138899/GitHub%20Wikis/level_component_treema.png)
See the "Configuration Schema" part toward the bottom? We can use the Treema GUI to generate another JSON Schema that then can be made into another Treema GUI which can let anyone configure anything with a GUI!
## Examples
Here's the schema returned by [http://codecombat.com/db/thang_component/schema](http://codecombat.com/db/thang_component/schema):
```json
{
"type": "object",
"additionalProperties": false,
"properties": {
"original": {
"type": [
"object",
"string"
],
"title": "Original",
"description": "A reference to the original Component being configured.",
"format": "hidden"
},
"config": {
"type": "object",
"additionalProperties": true,
"properties": {},
"title": "Configuration",
"description": "Component-specific configuration properties.",
"format": "thang-component-configuration"
},
"majorVersion": {
"title": "Major Version",
"description": "Which major version of the Component is being used.",
"type": "integer",
"minimum": 0,
"default": 0,
"format": "hidden"
}
},
"title": "Component",
"description": "Configuration for a Component that this Thang uses.",
"format": "thang-component",
"required": [
"original",
"majorVersion"
],
"default": {
"majorVersion": 0,
"config": {}
},
"links": [
{
"rel": "db",
"href": "/db/level.component/{(original)}/version/{(majorVersion)}"
}
]
}
```