{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://sonos.svrooij.io/schema/documentation.json",
  "definitions": {
    "SonosServiceDocumentation": {
      "title": "Service name",
      "description": "The name of the service should match exactly to the name in the Service Discovery",
      "properties": {
        "actions": {
          "title": "Actions in this service",
          "additionalProperties": {
            "$ref": "#/definitions/SonosServiceDocumentationAction"
          },
          "type": "object"
        },
        "description": {
          "type": "string"
        },
        "errors": {
          "title": "Custom errors for this service",
          "type": "array",
          "items": {
            "$ref": "#/definitions/SonosCustomError"
          }
        },
        "variables": {
          "title": "Service variables",
          "type": "array",
          "items": {
            "$ref": "#/definitions/SonosServiceVariable"
          }
        }
      },
      "type": "object",
      "required": ["description"]
    },
    "SonosServiceDocumentationAction": {
      "title": "Action name",
      "description": "The name of the action should match exactly with the Service Discovery",
      "properties": {
        "description": {
          "title": "Short description of action",
          "type": "string"
        },
        "params": {
          "title": "Action parameters",
          "additionalProperties": {
            "title": "Parameter description",
            "description": "Describe a single input/output argument, by it name as key",
            "type": "string"
          },
          "type": "object"
        },
        "sample": {
          "title": "Sample values",
          "description": "Sample values for the parameters",
          "additionalProperties": {
            "title": "Value",
            "description": "Working value, by it name as key",
            "type": "string"
          },
          "type": "object"
        },
        "remarks": {
          "title": "Action remarks",
          "description": "Remarks about this action",
          "type": "string"
        }
      },
      "type": "object",
      "required": ["description"]
    },
    "SonosCustomError": {
      "title": "Custom error",
      "description": "Sonos defined custom errors per UPNP Service.",
      "properties": {
        "code": {
          "title": "Error code",
          "type": "number"
        },
        "description": {
          "title": "Error description",
          "type":"string"
        }
      },
      "default": {
        "code": 0,
        "description": ""
      },
      "type": "object",
      "required": ["code", "description"]
    },
    "SonosServiceVariable": {
      "title": "Service variable",
      "description": "Used for variable description and additional event properties",
      "type": "object",
      "properties": {
        "name": {
          "title": "Name of the event",
          "type": "string"
        },
        "dataType": {
          "type": "string",
          "enum": ["string", "boolean", "ui2", "i4", "ui4"]
        },
        "description": {
          "type":"string",
          "title": "Optional description"
        }
      },
      "required": ["name", "dataType"]
    }
  },
  "properties": {
    "license": {
      "title": "License of the current documentation, MIT is required to be included into the generator",
      "type": "string",
      "default": "MIT"
    },
    "language": {
      "type": "string",
      "title": "Language of the current documentation"
    },
    "services": {
      "title": "Each service is added with it's name as key",
      "additionalProperties": {
        "$ref": "#/definitions/SonosServiceDocumentation"
      },
      "type": "object"
    },
    "errors": {
      "title": "Default errors",
      "description": "These errors are used in all services.",
      "type": "array",
      "items": {
        "$ref": "#/definitions/SonosCustomError"
      }
    }
  },
  "type": "object",
  "required": ["license", "services", "language"]
}