{
  "openapi": "3.0.3",
  "info": {
    "title": "soar",
    "version": "1.0",
    "description": "SoAR message schemas"
  },
  "paths": {},
  "components": {
    "schemas": {
      "Message": {
        "properties": {
          "metadata": {
            "$ref": "#/components/schemas/Metadata"
          },
          "payload": {
            "$ref": "#/components/schemas/Payload"
          }
        },
        "required": ["metadata", "payload"]
      },
      "Payload": {
        "discriminator": {
          "propertyName": "message_type",
          "mapping": {
            "VehicleStatus": "#/components/schemas/VehicleStatus",
            "VehicleMission": "#/components/schemas/VehicleMission",
            "AreaOfInterest": "#/components/schemas/AreaOfInterest"
          }
        },
        "oneOf": [
          {
            "$ref": "#/components/schemas/VehicleStatus"
          },
          {
            "$ref": "#/components/schemas/VehicleMission"
          },
          {
            "$ref": "#/components/schemas/AreaOfInterest"
          }
        ]
      },
      "Metadata": {
        "properties": {
          "source": {
            "type": "string",
            "description": "The sender.",
            "example": "autonomy-engine"
          },
          "destination": {
            "type": "string",
            "description": "Publisher topic.",
            "example": "soar.noc.autosub.ah1.status"
          },
          "delivery_type": {
            "type": "string",
            "description": "Published or broadcast",
            "enum": ["broadcast", "publish"],
            "example": "2.0.0"
          },
          "message_id": {
            "type": "string",
            "description": "An identifier for the type of message received.",
            "example": "VehicleStatus"
          }
        },
        "required": ["source","destination","message_id"],
        "type": "object"
      },
      "Coordinates": {
        "properties": {
          "latitude": {
            "type": "number",
            "description": "Latitude in decimal degrees.",
            "example": 54.234
          },
          "longitude": {
            "type": "number",
            "description": "Longitude in decimal degrees.",
            "example": -1.432
          },
          "depth": {
            "type": "number",
            "description": "Target depth",
            "default": 0,
            "example": 50
          },
          "altitude": {
            "type": "number",
            "description": "Target altitude above bottom",
            "default": 0,
            "example": 50
          },
          "projection": {
            "type": "integer",
            "description": "EPSG Projection Code",
            "example": 4326,
            "default": 4326
          }
        },
        "required": ["latitude", "longitude"],
        "type": "object"
      },
      "VehicleStatus": {
        "properties": {
          "message_type": {
            "type": "string",
            "description": "An identifier for the payload type.",
            "example": "VehicleStatus",
            "enum": ["VehicleStatus"]
          },
          "operator_id": {
            "type": "string",
            "description": "An identifier for the operator.",
            "example": "noc"
          },
          "vehicle_id": {
            "type": "string",
            "description": "An identifier for the vehicle.",
            "example": "noc_ah1"
          },
          "coordinates": {
            "$ref": "#/components/schemas/Coordinates"
          },
          "battery_percentage": {
            "type": "number",
            "description": "The remaining battery capacity.",
            "example": 64
          }
        },
        "required": ["message_type", "operator_id", "vehicle_id", "coordinates", "battery_percentage"],
        "type": "object"
      },
      "VehicleMission": {
        "properties": {
          "message_type": {
            "type": "string",
            "description": "An identifier for the payload type.",
            "example": "VehicleMission",
            "enum": ["VehicleMission"]
          },
          "operator_id": {
            "type": "string",
            "description": "An identifier for the operator.",
            "example": "noc"
          },
          "vehicle_id": {
            "type": "string",
            "description": "An identifier for the vehicle.",
            "example": "noc_ah1"
          },
          "coordinates": {
            "$ref": "#/components/schemas/Coordinates"
          },
          "actions": {
            "type": "array",
            "items": {
              "discriminator": {
                "propertyName": "action_type",
                "mapping": {
                  "GoToWaypoint": "#/components/schemas/GoToWaypoint",
                  "DescendToAltitude": "#/components/schemas/DescendToAltitude",
                  "AscendToSurface": "#/components/schemas/AscendToSurface"
                }
              },
              "oneOf": [
                {
                  "$ref": "#/components/schemas/GoToWaypoint"
                },
                {
                  "$ref": "#/components/schemas/DescendToAltitude"
                },
                {
                  "$ref": "#/components/schemas/AscendToSurface"
                }
              ]
            }
          }
        },
        "required": ["message_type", "operator_id", "vehicle_id", "coordinates", "actions"],
        "type": "object"
      },
      "AreaOfInterest": {
        "properties": {
          "message_type": {
            "type": "string",
            "description": "An identifier for the payload type.",
            "example": "AreaOfInterest",
            "enum": ["AreaOfInterest"]
          },
          "operator_id": {
            "type": "string",
            "description": "An identifier for the operator.",
            "example": "noc"
          },
          "vehicle_id": {
            "type": "string",
            "description": "An identifier for the vehicle.",
            "example": "noc_ah1"
          },
          "coordinates": {
            "$ref": "#/components/schemas/Coordinates"
          }
        },
        "required": ["message_type", "operator_id", "vehicle_id", "coordinates"],
        "type": "object"
      },
      "GoToWaypoint": {
        "properties": {
          "action_type": {
            "type": "string",
            "description": "An identifier for the payload type.",
            "example": "GoToWaypoint",
            "enum": ["GoToWaypoint"]
          },
          "coordinates": {
            "$ref": "#/components/schemas/Coordinates"
          }
        },
        "type": "object"
      },
      "DescendToAltitude": {
        "properties": {
          "action_type": {
            "type": "string",
            "description": "An identifier for the payload type.",
            "example": "DescendToAltitude",
            "enum": ["DescendToAltitude"]
          },
          "coordinates": {
            "$ref": "#/components/schemas/Coordinates"
          }
        },
        "type": "object"
      },
      "AscendToSurface": {
        "properties": {
          "action_type": {
            "type": "string",
            "description": "An identifier for the payload type.",
            "example": "AscendToSurface",
            "enum": ["AscendToSurface"]
          },
          "coordinates": {
            "$ref": "#/components/schemas/Coordinates"
          }
        },
        "type": "object"
      }
    }
  }
}