{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "definitions": {
        "state": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string"
                },
                "type": {
                    "type": "string"
                }
            },
            "required": [
                "name",
                "type"
            ]
        },
        "sub": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string"
                },
                "states": {
                    "type": "array",
                    "items": {
                        "anyOf": [
                            {
                                "$ref": "#/definitions/state"
                            },
                            {
                                "$ref": "#/definitions/sub"
                            },
                            {
                                "$ref": "#/definitions/parallel"
                            }
                        ]
                    }
                },
                "type": {
                    "type": "string"
                }
            },
            "required": [
                "name",
                "type",
                "states"
            ]
        },
        "parallel": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string"
                },
                "regions": {
                    "type": "array",
                    "items": {
                        "type": "array",
                        "items": {
                            "anyOf": [
                                {
                                    "$ref": "#/definitions/state"
                                },
                                {
                                    "$ref": "#/definitions/sub"
                                },
                                {
                                    "$ref": "#/definitions/parallel"
                                }
                            ]
                        }
                    }
                },
                "type": {
                    "type": "string"
                }
            },
            "required": [
                "name",
                "type",
                "regions"
            ]
        },
        "transition": {
            "type": "object",
            "properties": {
                "kind": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                },
                "source": {
                    "type": "string"
                },
                "target": {
                    "type": "string"
                }
            },
            "required": [
                "name",
                "kind",
                "type",
                "source",
                "target"
            ]
        },
        "compound_transition": {
            "type": "object",
            "properties": {
                "type": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                },
                "vertices": {
                    "type": "object",
                    "properties": {
                        "incoming": {
                            "type": "array",
                            "items": {
                                "type": "object",
                                "properties": {
                                    "source": {
                                        "type": "string"
                                    },
                                    "name": {
                                        "type": "string"
                                    }
                                },
                                "required": [
                                    "source",
                                    "name"
                                ]
                            }
                        },
                        "outgoing": {
                            "type": "array",
                            "items": {
                                "type": "object",
                                "properties": {
                                    "target": {
                                        "type": "string"
                                    }
                                },
                                "required": [
                                    "target"
                                ]
                            }
                        }
                    }
                },
                "pseudo_state": {
                    "type": "object",
                    "properties": {
                        "type": {
                            "type": "string"
                        },
                        "name": {
                            "type": "string"
                        },
                        "region": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "name",
                        "type",
                        "region"
                    ]
                }
            },
            "required": [
                "name",
                "type",
                "vertices",
                "pseudo_state"
            ]
        }
    },
    "type": "object",
    "properties": {
        "name": {
            "type": "string"
        },
        "states": {
            "type": "array",
            "items": {
                "anyOf": [
                    {
                        "$ref": "#/definitions/state"
                    },
                    {
                        "$ref": "#/definitions/sub"
                    },
                    {
                        "$ref": "#/definitions/parallel"
                    }
                ]
            }
        },
        "transitions": {
            "type": "array",
            "items": {
                "anyOf": [
                    {
                        "$ref": "#/definitions/transition"
                    },
                    {
                        "$ref": "#/definitions/compound_transition"
                    }
                ]
            }
        }
    }
}