A guardrail means that it must be checked against.
| JsonSchema Property | AvroSchema Support | IsConvertable | Description | Guardrail? |
|---|---|---|---|---|
| AnyOf | Union (Somewhat fit) | ✅ | ||
| AllOf | Not supported | ⛔ | This cannot be expressed in Avro | Yes |
| OneOf | Union (Best fit) | ✅ | ||
| Nullable | Union (null + another Type) | ✅ | ||
| Title | Schema.Name | ✅ | Must be guardrail as avro requires "Name" for its types. | Yes |
| Type | AvroRecord, AvroArray, AvroMap, AvroEnum (with Symbols) or primitive (see picture) | ✅ | Must be guardrailed as avro needs a type to convert into. | Yes |
| Description | Schema.Doc | ✅ | ||
| Default | Field:Default | ✅ | ||
| Properties | Record.Fields | ✅ | ||
| PatternProperties | ⛔ | This cannot be expressed in Avro | ||
| ExternalDocs | ⛔ | There is only "Doc" which is better suited as a description. | ||
| Items | If Array, AvroArray.Items | ✅ | ||
| AdditionalItems | ⛔ | This cannot be expressed in Avro | ||
| Deprecated | ⛔ | This cannot be expressed in Avro | ||
| Enum | Enum - only if string though. | ✅ | Maybe? |
JsonSchema
Avro
{
"type": "record", // Inferred from 'Properties' being present
"name": "Example Schema", // 'Title'
"doc": "An example schema representing a person", // 'Description'
"fields": [ // 'Properties'
{"name": "name", "type": "string"},
{"name": "age", "type": "int", "default": 50},
{
"type": "record",
"name": "Address",
"fields": [
{"name": "street", "type": "string"},
{"name": "zip", "type": "int"}
]
},
{
"name": "Wishes",
"type": "array", // inferred from 'Items' being present.
"items": [ // if type has 'oneOf'/'anyOf' map to Union
{
"type": "record", // Inferred from 'Properties' being present
"name": "Wish1", // Infer from name add count?
"fields": [ // 'Properties'
{"name": "name", "type": "string"},
{"name": "description", "type": "string"}
]
},
{
"type": "record", // Inferred from 'Properties' being present
"name": "Wish2", // Infer from name add count?
"fields": [ // 'Properties'
{"name": "url", "type": "string"}
]
},
{ "type": "null" } // primitive null.
]
},
{
"name": "Animals",
"type": "array", // inferred from 'Items' being present.
"items": {
"type": "record", // inferred from 'Properties' being present.
"name":"animal", // 'Title'
"fields": [ // 'Properties'
{"name": "name", "type": "string"},
{"name": "characteristic", "type": "string"}
]
}
},
{
"name": "Hobbies",
"type": "array", // inferred from 'Items' being present.
"items": "string" // No default, 'Type' was a primitive
},
{
"name": "grade",
"type": "enum", // Inferred from 'Enum' being present
"symbols": ["A", "B", "C", "D"]
}
]
}
{ "title": "Example Schema", "description": "An example schema representing a person", "type": "object", "properties": { "name": {"type": "string"}, "age": {"type": "integer", "minimum": 18, "maximum": 120, "default": 50}, "address": { "type": "object", "properties": { "street": {"type": "string"}, "zip": {"type": "integer"} }, "required": ["street", "zip"] }, "Wishes": { "type": "array", "items": { "oneOf": [ {"properties": {"name": {"type": "string"}, "description": {"type": "string"}}}, {"properties": {"url": {"type": "string"}}}, {"type": "null"} ] } }, "Animals": { "items": { "title": "animal", "properties": {"name": {"type": "string"}, "characteristic": {"type": "string"}}}, }, "Hobbies": { "type": "array", "items": {"type": "string", "default": "baseball"} }, "grade": {"type": "enum", "enum": ["A", "B", "C", "D"]} } }