{
    "id": "https://raw.githubusercontent.com/rolfvreijdenberger/jsend-json-schema/master/jsend-json-schema.json",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "jsend json schema",
    "description": "This is a json-schema for the jsend format for json responses for applications. see https://labs.omniti.com/labs/jsend/wiki",
    "type": "object",
    "oneOf": [
        {
            "$ref": "#/definitions/success"
        },
        {
            "$ref": "#/definitions/fail"
        },
        {
            "$ref": "#/definitions/error"
        }
    ],
    "definitions": {
        "success": {
            "description": "All went well, and (usually) some data was returned.",
            "required": [
                "status",
                "data"
            ],
            "properties": {
                "status": {
                    "type": "string",
                    "pattern": "^success$",
                    "description": "the status for a succesful handling"
                },
                "data": {
                    "description": "Acts as the wrapper for any data returned by the API call. If the call returns no data (as in the last example), data should be set to null.",
                    "$ref": "#/definitions/data"
                }
            }
        },
        "fail": {
            "description": "There was a problem with the data submitted, or some pre-condition of the API call wasn't satisfied",
            "required": [
                "status",
                "data"
            ],
            "properties": {
                "status": {
                    "type": "string",
                    "pattern": "^fail$",
                    "description": "the status for a failure handling"
                },
                "data": {
                    "description": "provides the wrapper for the details of why the request failed. If the reasons for failure correspond to POST values, the response object's keys SHOULD correspond to those POST values.",
                    "$ref": "#/definitions/data"
                }
            }
        },
        "error": {
            "description": "An error occurred in processing the request, i.e. an exception was thrown",
            "required": [
                "status",
                "message"
            ],
            "properties": {
                "status": {
                    "type": "string",
                    "pattern": "^error$",
                    "description": "the status for a error handling"
                },
                "message": {
                    "$ref": "#/definitions/message"
                },
                "code": {
                    "$ref": "#/definitions/code"
                },
                "data": {
                    "description": "A generic container for any other information about the error, i.e. the conditions that caused the error, stack traces, etc.",
                    "$ref": "#/definitions/data"
                }
            }
        },
        "data": {
            "description": "a generic container for data returned for success, fail or error",
            "type": [
                "string",
                "null",
                "array",
                "object",
                "integer",
                "boolean"
            ]
        },
        "code": {
            "description": "A numeric code corresponding to the error in an error result, if applicable",
            "type": [
                "string",
                "integer"
            ]
        },
        "message": {
            "description": "A meaningful, end-user-readable (or at the least log-worthy) message, explaining what went wrong in an error result.",
            "type": "string"
        }
    }
}