{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "VRT to CWE Mapping",
    "description": "Mapping from the Vulnerability Rating Taxonomy to CWE",
    "definitions": {
        "MappingMetadata": {
            "type": "object",
            "properties": {
                "default": {
                    "type": "null"
                }
            },
            "required": [
                "default"
            ]
        },
        "VRTid": {
            "type": "string",
            "pattern": "^[a-z_]*$"
        },
        "CWE": {
            "type": [
                "array",
                "null"
            ],
            "items": {
                "type": "string",
                "pattern": "^CWE-[0-9]*$"
            },
            "minItems": 1,
            "_uniqueItems": true
        },
        "Mapping": {
            "type": "object",
            "properties": {
                "id": {
                    "$ref": "#/definitions/VRTid"
                },
                "cwe": {
                    "$ref": "#/definitions/CWE"
                }
            },
            "required": [
                "id",
                "cwe"
            ],
            "additionalProperties": false
        },
        "MappingParent": {
            "type": "object",
            "properties": {
                "id": {
                    "$ref": "#/definitions/VRTid"
                },
                "children": {
                    "type": "array",
                    "items": {
                        "anyOf": [
                            {
                                "$ref": "#/definitions/MappingParent"
                            },
                            {
                                "$ref": "#/definitions/Mapping"
                            }
                        ]
                    }
                },
                "cwe": {
                    "$ref": "#/definitions/CWE"
                }
            },
            "required": [
                "id",
                "children"
            ],
            "additionalProperties": false
        }
    },
    "type": "object",
    "required": [
        "metadata",
        "content"
    ],
    "properties": {
        "metadata": {
            "$ref": "#/definitions/MappingMetadata"
        },
        "content": {
            "type": "array",
            "items": {
                "anyOf": [
                    {
                        "$ref": "#/definitions/MappingParent"
                    },
                    {
                        "$ref": "#/definitions/Mapping"
                    }
                ]
            }
        }
    }
}