{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "id" : "https://raw.githubusercontent.com/common-workflow-language/common-workflow-language/draft-1/schemas/metaschema.json",
    "description": "Meta-schema for describing tool inputs and outputs",
    "definitions": {
        "schemaArray": {
            "type": "array",
            "minItems": 1,
            "items": { "$ref": "#" }
        },
        "positiveInteger": {
            "type": "integer",
            "minimum": 0
        },
        "positiveIntegerDefault0": {
            "allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ]
        },
        "simpleTypes": {
            "enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ]
        },
        "stringArray": {
            "type": "array",
            "items": { "type": "string" },
            "minItems": 1,
            "uniqueItems": true
        },
        "secondaryFile": {
            "type": "object",
            "required": ["path"],
            "properties": {
                "path": { "type": "string" },
                "size": { "type": "number" },
                "checksum": { "type": "string" },
                "metadata": { "type": "object" }
            }
        },
        "file": {
            "type": "object",
            "required": ["path"],
            "properties": {
                "path": { "type": "string" },
                "size": { "type": "number" },
                "checksum": { "type": "string" },
                "secondaryFiles": {
                    "type": "array",
                    "items": { "$ref": "#/definitions/secondaryFile" }
                },
                "metadata": { "type": "object" }
            }
        },
        "$job": {
            "type": "object",
            "required": ["$job"],
            "properties": {
                "$job": { "type": "string" }
            }
        }
    },
    "type": "object",
    "properties": {
        "title": {
            "type": "string"
        },
        "description": {
            "type": "string"
        },
        "default": {},
        "multipleOf": {
            "type": "number",
            "minimum": 0,
            "exclusiveMinimum": true
        },
        "maximum": {
            "type": "number"
        },
        "exclusiveMaximum": {
            "type": "boolean",
            "default": false
        },
        "minimum": {
            "type": "number"
        },
        "exclusiveMinimum": {
            "type": "boolean",
            "default": false
        },
        "maxLength": { "$ref": "#/definitions/positiveInteger" },
        "minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
        "pattern": {
            "type": "string",
            "format": "regex"
        },
        "items": {
            "anyOf": [
                { "$ref": "#" },
                { "$ref": "#/definitions/schemaArray" }
            ],
            "default": {}
        },
        "maxItems": { "$ref": "#/definitions/positiveInteger" },
        "minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
        "uniqueItems": {
            "type": "boolean",
            "default": false
        },
        "maxProperties": { "$ref": "#/definitions/positiveInteger" },
        "minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
        "required": {
            "anyOf": [
                { "$ref": "#/definitions/stringArray" },
                { "$type": "boolean" }
            ]
        },
        "definitions": {
            "type": "object",
            "default": {}
        },
        "properties": {
            "type": "object",
            "default": {}
        },
        "dependencies": {
            "type": "object"
        },
        "enum": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true
        },
        "type": {
            "anyOf": [
                { "$ref": "#/definitions/simpleTypes" },
                {
                    "type": "array",
                    "items": { "$ref": "#/definitions/simpleTypes" },
                    "minItems": 1,
                    "uniqueItems": true
                }
            ]
        },
        "oneOf": { "$ref": "#/definitions/schemaArray" }
    },
    "dependencies": {
        "exclusiveMaximum": [ "maximum" ],
        "exclusiveMinimum": [ "minimum" ]
    },
    "adapter": {
        "type": "object",
        "properties": {
            "prefix": { "type": "string" },
            "order": { "type": "integer" },
            "separator": { "type": "string" },
            "itemSeparator": { "type": "string" },
            "streamable": { "type": "boolean" },
            "glob": { "type": "string" }
        }
    },
    "default": {}
}
