Skip to content

Instantly share code, notes, and snippets.

@jeremiegirault
Created April 15, 2021 07:54
Show Gist options
  • Save jeremiegirault/5afa4d52e4f8ef6ea63b01caf27d9f24 to your computer and use it in GitHub Desktop.
Save jeremiegirault/5afa4d52e4f8ef6ea63b01caf27d9f24 to your computer and use it in GitHub Desktop.
JTD JSON Schema Draft
{
"type": "object",
"$ref": "#/$defs/anyForm",
"properties": {
"definitions": {
"type": "object",
"additionalProperties": { "$ref": "#/$defs/anyForm" }
}
},
"$defs": {
"anyForm": {
"type": "object",
"oneOf": [
{ "$ref": "#/$defs/emptyForm" },
{ "$ref": "#/$defs/typeForm" },
{ "$ref": "#/$defs/enumForm" },
{ "$ref": "#/$defs/elementsForm" },
{ "$ref": "#/$defs/propertiesForm" },
{ "$ref": "#/$defs/valuesForm" },
{ "$ref": "#/$defs/discriminatorForm" },
{ "$ref": "#/$defs/refForm" }
],
"properties": {
"nullable": { "type": "boolean" },
"metadata": { "type": "object" }
}
},
"emptyForm": {
"type": "object"
},
"typeForm": {
"properties": {
"type": {
"enum": [ "boolean", "string", "timestamp", "float32", "float64", "int8", "uint8", "int16", "uint16", "int32", "uint32" ]
}
},
"required": [ "type" ]
},
"enumForm": {
"properties": {
"enum": {
"type": "array",
"items": { "type": "string" }
}
},
"required": [ "enum" ]
},
"elementsForm": {
"properties": {
"elements": { "$ref": "#/$defs/anyForm" }
},
"required": [ "elements" ]
},
"propertiesForm": {
"properties": {
"properties": {
"type": "object",
"additionalProperties": { "$ref": "#/$defs/anyForm" }
},
"optionalProperties": {
"type": "object",
"additionalProperties": { "$ref": "#/$defs/anyForm" }
},
"additionalProperties": { "type": "boolean" }
},
"required": [ "properties" ]
},
"valuesForm": {
"properties": {
"values": { "$ref": "#/$defs/anyForm" }
},
"required": [ "values" ]
},
"discriminatorForm": {
"properties": {
"discriminator": { "type": "string" },
"mapping": {
"type": "object",
"additionalProperties": { "$ref": "#/$defs/propertiesForm" }
}
},
"required": [ "discriminator", "mapping" ]
},
"refForm": {
"properties": {
"ref": { "type": "string" }
},
"required": [ "ref" ]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment