{
    "$schema": "http://json-schema.org/draft-04/schema",
    "title": "Completion Resource",
    "description": "A completion of a BEL expression.",
    "type": "object",
    "additionalProperties": false,
    "required": [
        "completion"
    ],
    "properties": {
        "completion": {
            "type": "object",
            "additionalProperties": false,
            "required": [
                "type",
                "label",
                "value",
                "highlight",
                "actions"
            ],
            "properties": {
                "type": {
                    "enum": [
                        "function",
                        "namespace_prefix",
                        "namespace_value"
                    ]
                },
                "label": {
                    "type": "string"
                },
                "value": {
                    "type": "string"
                },
                "highlight": {
                    "oneOf": [
                        {
                            "type": "null"
                        },
                        {
                            "type": "object",
                            "required": [
                                "start_position",
                                "end_position",
                                "range_type"
                            ],
                            "properties": {
                                "start_position": {
                                    "type": "integer"
                                },
                                "end_position": {
                                    "type": "integer"
                                },
                                "range_type": {
                                    "enum": [
                                        "exclusive",
                                        "inclusive"
                                    ]
                                }
                            }
                        }
                    ]
                },
                "actions": {
                    "type": "array",
                    "items": {
                        "oneOf": [
                            {
                                "type": "object",
                                "required": [
                                    "delete"
                                ],
                                "properties": {
                                    "delete": {
                                        "type": "object",
                                        "required": [
                                            "start_position",
                                            "end_position",
                                            "range_type"
                                        ],
                                        "properties": {
                                            "start_position": {
                                                "type": "integer"
                                            },
                                            "end_position": {
                                                "type": "integer"
                                            },
                                            "range_type": {
                                                "enum": [
                                                    "exclusive",
                                                    "inclusive"
                                                ]
                                            }
                                        }
                                    }
                                }
                            },
                            {
                                "type": "object",
                                "required": [
                                    "insert"
                                ],
                                "properties": {
                                    "insert": {
                                        "type": "object",
                                        "required": [
                                            "position",
                                            "value"
                                        ],
                                        "properties": {
                                            "position": {
                                                "type": "integer"
                                            },
                                            "value": {
                                                "type": "string"
                                            }
                                        }
                                    }
                                }
                            },
                            {
                                "type": "object",
                                "required": [
                                    "move_cursor"
                                ],
                                "properties": {
                                    "move_cursor": {
                                        "type": "object",
                                        "required": [
                                            "position"
                                        ],
                                        "properties": {
                                            "position": {
                                                "type": "integer"
                                            }
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }
            }
        }
    }
}