-
Notifications
You must be signed in to change notification settings - Fork 37
Understanding the Generated JSON Schema
Alexey Valikov edited this page May 2, 2015
·
18 revisions
If you've turned on the JSON Schema generation, Jsonix Schema Compiler will produce one more JSON Schema files for each your modules according to the configuration.
We'll start with a single-maping module, that is, a module which contains just one mapping (see Modules and Mappings for more information).
The JSON Schema for a single-mapping module will contain:
- the
id
of the schema (see Mapping Configuration); - the
definitions
sections which declares complex and enum types; - the
anyOf
section which lists possible top-level elements as qualified name/expected value type pair.
Here's what it looks like:
{
"id":"MyMapping.jsonschema#",
"definitions":{
"MyComplexType":{ "type":"object", ... },
"MyEnumType":{ "type":"string", ... },
...
},
"anyOf":[
{
"type":"object",
"properties":{
"name":{
"$ref":"http://www.jsonix.org/jsonschemas/w3c/2001/XMLSchema.jsonschema#/definitions/QName"
},
"value":{
"$ref":"#/definitions/MyComplexType"
}
},
"elementName":{
"localPart":"myComplexElement",
"namespaceURI":""
}
},
...
]
}
If the module contains several mappings, it's structure will be a bit more complex:
- the module schema will get its own schema
id
(see Module Configuration); - the
definitions
sections will contain schemas for individual mappings; - the
anyOf
section will refer to the schemas of the individual mappings via$ref
-id
.
Here's what it looks like:
{
"id":"A_B.jsonschema#",
"definitions":{
"A":{"id":"A.jsonschema#", "definitions" : {...}, "anyOf" : [ ... ]}
"B":{"id":"B.jsonschema#", "definitions" : {...}, "anyOf" : [ ... ]}
},
"anyOf":[
{ "$ref":"A.jsonschema#" },
{ "$ref":"B.jsonschema#" }
]
}
- Usage
- Basic Concepts
- Generation
- Configuration
- Advanced Topics
- Sample Projects
- Troubleshooting
- Development