{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "TransformSpec",
    "description": "Specification of an image transform",
    "type": "object",
    "anyOf": [
        {
            "$ref": "#/definitions/interpolatedTransformSpec"
        },
        {
            "$ref": "#/definitions/leafTransformSpec"
        },
        {
            "$ref": "#/definitions/listTransformSpec"
        },
        {
            "$ref": "#/definitions/referenceTransformSpec"
        }
    ],
    "definitions": {
        "anyTransformSpec": {
            "description": "set of possible transform specification types",
            "type": "object",
            "anyOf": [
                {
                    "$ref": "#/definitions/interpolatedTransformSpec"
                },
                {
                    "$ref": "#/definitions/leafTransformSpec"
                },
                {
                    "$ref": "#/definitions/listTransformSpec"
                },
                {
                    "$ref": "#/definitions/referenceTransformSpec"
                }
            ]
        },
        "interpolatedTransformSpec": {
            "description": "specification for an interpolation between 2 transforms",
            "type": "object",
            "properties": {
                "type": {
                    "enum": [
                        "interpolated"
                    ]
                },
                "id": {
                    "$ref": "#/definitions/transformId"
                },
                "metaData": {
                    "$ref": "#/definitions/transformMetaData"
                },
                "a": {
                    "$ref": "#/definitions/anyTransformSpec"
                },
                "b": {
                    "$ref": "#/definitions/anyTransformSpec"
                },
                "lambda": {
                    "type": "number"
                }
            },
            "required": [
                "type",
                "a",
                "b",
                "lambda"
            ]
        },
        "leafTransformSpec": {
            "description": "specification for a transform that can be directly implemented",
            "type": "object",
            "properties": {
                "id": {
                    "$ref": "#/definitions/transformId"
                },
                "metaData": {
                    "$ref": "#/definitions/transformMetaData"
                },
                "className": {
                    "description": "full Java class name for transform implementation",
                    "type": "string"
                },
                "dataString": {
                    "description": "properties specifying the transformation",
                    "type": "string"
                }
            },
            "required": [
                "className",
                "dataString"
            ]
        },
        "listTransformSpec": {
            "description": "ordered list of transform specifications",
            "type": "object",
            "properties": {
                "id": {
                    "$ref": "#/definitions/transformId"
                },
                "metaData": {
                    "$ref": "#/definitions/transformMetaData"
                },
                "type": {
                    "enum": [
                        "list"
                    ]
                },
                "specList": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/anyTransformSpec"
                    }
                }
            },
            "required": [
                "type",
                "specList"
            ]
        },
        "referenceTransformSpec": {
            "description": "reference to another transform specification",
            "type": "object",
            "properties": {
                "type": {
                    "enum": [
                        "ref"
                    ]
                },
                "id": {
                    "$ref": "#/definitions/transformId"
                },
                "metaData": {
                    "$ref": "#/definitions/transformMetaData"
                },
                "refId": {
                    "$ref": "#/definitions/transformId"
                }
            },
            "required": [
                "type",
                "refId"
            ]
        },
        "transformId": {
            "description": "uniquely identifies transform specification",
            "type": "string"
        },
        "transformMetaData": {
            "description": "any data about the transform that is not needed for rendering",
            "type": "object",
            "properties": {
                "labels": {
                    "description": "set of labels for a transform",
                    "type": "array",
                    "_uniqueItems": true,
                    "items": {
                        "type": "string"
                    }
                }
            }
        }
    }
}