{
    "$schema"               : "http://json-schema.org/draft-04/schema#",
    "id"                    : "https://eddn.edcd.io/schemas/fsssignaldiscovered/1#",
    "description"           : "EDDN schema for FSSSignalDiscovered Journal events.  Full documentation at https://github.com/EDCD/EDDN/tree/master/schemas/fsssignaldiscovered-README.md",
    "type"                  : "object",
    "additionalProperties"  : false,
    "required": [ "$schemaRef", "header", "message" ],
    "properties": {
        "$schemaRef": {
            "type"                  : "string"
        },
        "header": {
            "type"                  : "object",
            "additionalProperties"  : true,
            "required"              : [ "uploaderID", "softwareName", "softwareVersion" ],
            "properties"            : {
                "uploaderID": {
                    "type"          : "string"
                },
                "gameversion": {
                    "type"          : "string",
                    "description"   : "From Fileheader event if available, else LoadGame if available there."
                },
                "gamebuild": {
                    "type"          : "string",
                    "description"   : "The `build` value from a Fileheader event if available, else LoadGame if available there."
                },
                "softwareName": {
                    "type"          : "string"
                },
                "softwareVersion": {
                    "type"          : "string"
                },
                "gatewayTimestamp": {
                    "type"          : "string",
                    "format"        : "date-time",
                    "description"   : "Timestamp upon receipt at the gateway. If present, this property will be overwritten by the gateway; submitters are not intended to populate this property."
                }
            }
        },
        "message": {
            "type"                  : "object",
            "description"           : "Contains all properties from the listed events in the client's journal minus Localised strings and the properties marked below as 'disallowed'",
            "additionalProperties"  : false,
            "required"              : [ "event", "timestamp", "SystemAddress", "StarSystem", "StarPos", "signals"],
            "properties"            : {
                "event": {
                    "enum"          : [ "FSSSignalDiscovered" ]
                },
                "horizons": {
                    "type"          : "boolean",
                    "description"   : "Whether the sending Cmdr has a Horizons pass."
                },
                "odyssey": {
                    "type"      : "boolean",
                    "description" : "Whether the sending Cmdr has an Odyssey expansion."
                },
                "timestamp": {
                    "type"          : "string",
                    "format"        : "date-time",
                    "description"   : "Duplicate of the first signal's timestamp, for commonality with other schemas."
                },
                "SystemAddress": {
                    "type": "integer"
                },
                "signals": {
                    "type": "array",
                    "description": "Array of FSSSignalDiscovered events",
                    "minItems": 1,
                    "items": {
                        "type": "object",
                        "additionalProperties"  : false,
                        "required": ["timestamp", "SignalName"],
                        "description": "Single FSSSignalDiscovered event",
                        "properties": {
                            "timestamp": {
                                "type"          : "string",
                                "format"        : "date-time"
                            },
                            "SignalName": { "type":  "string" },
                            "SignalType": { "type":  "string" },
                            "IsStation": { "type": "boolean" },
                            "USSType": {
                              "type": "string",
                               "not": {
                                    "pattern": "^\\$USS_Type_MissionTarget;$"
                                }
                            },
                            "TimeRemaining": {"$ref" : "#/definitions/disallowed"},
                            "SpawningState": {"type":  "string"},
                            "SpawningFaction" : {"type":  "string"},
                            "SpawningPower" : {"type":  "string"},
                            "OpposingPower" : {"type":  "string"},
                            "ThreatLevel": {"type": "integer" },

                            "patternProperties": {
                                "_Localised$"       : { "$ref" : "#/definitions/disallowed" }
                            }
                        }
                    }
                },
                "StarSystem": {
                    "type"          : "string",
                    "minLength"     : 1,
                    "description": "Should be added by the sender"
                },
                "StarPos": {
                    "type"          : "array",
                    "items"         : { "type": "number" },
                    "minItems"      : 3,
                    "maxItems"      : 3,
                    "description"   : "Should be added by the sender"
                }
            }
        }
    },
    "definitions": {
        "disallowed" : { "not" : { "type": [ "array", "boolean", "integer", "number", "null", "object", "string" ] } }
    }
}
