{
  "asyncapi": "3.1.0",
  "id": "urn:waraps.api-map-objects",
  "info": {
    "title": "WARA-PS Map Objects MQTT API",
    "version": "1.0.3",
    "description": "### Overview\nMap object definitions for the WARA-PS system. Defines channels, operations, and message schemas for publishing map objects (areas, circles, points, and paths) via MQTT.\n\n### Channels\n- **Point** — Publishes a point map object.\n- **Path** — Publishes a path map object.\n- **Area Polygon** — Publishes a polygon area map object.\n- **Area Circle** — Publishes a circle area map object.",
    "contact": {
      "name": "waraps.org",
      "url": "https://portal.waraps.org/",
      "email": "info@waraps.org"
    },
    "license": {
      "name": "Apache 2.0",
      "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
    }
  },
  "defaultContentType": "application/json",
  "servers": {
    "localhost": {
      "host": "localhost:1883",
      "protocol": "mqtt",
      "protocolVersion": "3.1.1+",
      "description": "Development MQTT broker",
      "variables": {
        "port": {
          "enum": [
            "1882",
            "1883"
          ],
          "default": "1883",
          "description": "The port used for connecting to the locally hosted MQTT broker"
        }
      },
      "security": []
    },
    "production": {
      "host": "broker.waraps.org:8883",
      "protocol": "mqtt",
      "protocolVersion": "3.1.1+",
      "description": "Production MQTT broker",
      "variables": {
        "port": {
          "enum": [
            "8883"
          ],
          "default": "8883",
          "description": "The port used for connecting to the production MQTT broker"
        }
      },
      "security": [
        {
          "$ref": "#/components/securitySchemes/tls"
        }
      ]
    }
  },
  "channels": {
    "mapObjectPointChannel": {
      "address": "{MapObjectBaseTopic}/{name}-P",
      "bindings": {
        "$ref": "#/components/channelBindings/MapObjectMqttSettings"
      },
      "messages": {
        "sendMapObjectPoint.message": {
          "$ref": "#/components/messages/MapObjectPointMessage"
        }
      },
      "description": "Sends a point map object. Topic name must end with -P.",
      "parameters": {
        "MapObjectBaseTopic": {
          "$ref": "#/components/parameters/MapObjectBaseTopic"
        },
        "name": {
          "description": "Name of the map object (e.g., my-point).",
          "location": "$message.payload#/name"
        }
      }
    },
    "mapObjectPathChannel": {
      "address": "{MapObjectBaseTopic}/{name}-R",
      "bindings": {
        "$ref": "#/components/channelBindings/MapObjectMqttSettings"
      },
      "messages": {
        "sendMapObjectPath.message": {
          "$ref": "#/components/messages/MapObjectPathMessage"
        }
      },
      "description": "Sends a path/route map object. Topic name must end with -R.",
      "parameters": {
        "MapObjectBaseTopic": {
          "$ref": "#/components/parameters/MapObjectBaseTopic"
        },
        "name": {
          "description": "Name of the map object (e.g., my-route).",
          "location": "$message.payload#/name"
        }
      }
    },
    "mapObjectAreaPolygonChannel": {
      "address": "{MapObjectBaseTopic}/{name}-A",
      "bindings": {
        "$ref": "#/components/channelBindings/MapObjectMqttSettings"
      },
      "messages": {
        "sendMapObjectAreaPolygon.message": {
          "$ref": "#/components/messages/MapObjectAreaPolygonMessage"
        }
      },
      "description": "Sends a polygon area map object. Topic name must end with -A.",
      "parameters": {
        "MapObjectBaseTopic": {
          "$ref": "#/components/parameters/MapObjectBaseTopic"
        },
        "name": {
          "description": "Name of the map object (e.g., my-area).",
          "location": "$message.payload#/name"
        }
      }
    },
    "mapObjectAreaCircleChannel": {
      "address": "{MapObjectBaseTopic}/{name}-A",
      "bindings": {
        "$ref": "#/components/channelBindings/MapObjectMqttSettings"
      },
      "messages": {
        "sendMapObjectAreaCircle.message": {
          "$ref": "#/components/messages/MapObjectAreaCircleMessage"
        }
      },
      "description": "Sends a circle area map object. Topic name must end with -A.",
      "parameters": {
        "MapObjectBaseTopic": {
          "$ref": "#/components/parameters/MapObjectBaseTopic"
        },
        "name": {
          "description": "Name of the map object (e.g., my-circle).",
          "location": "$message.payload#/name"
        }
      }
    }
  },
  "operations": {
    "sendMapObjectPoint": {
      "action": "send",
      "channel": {
        "$ref": "#/channels/mapObjectPointChannel"
      },
      "summary": "Publishes point map object",
      "messages": [
        {
          "$ref": "#/channels/mapObjectPointChannel/messages/sendMapObjectPoint.message"
        }
      ]
    },
    "sendMapObjectPath": {
      "action": "send",
      "channel": {
        "$ref": "#/channels/mapObjectPathChannel"
      },
      "summary": "Publishes path/route map object",
      "messages": [
        {
          "$ref": "#/channels/mapObjectPathChannel/messages/sendMapObjectPath.message"
        }
      ]
    },
    "sendMapObjectAreaPolygon": {
      "action": "send",
      "channel": {
        "$ref": "#/channels/mapObjectAreaPolygonChannel"
      },
      "summary": "Publishes polygon area map object",
      "messages": [
        {
          "$ref": "#/channels/mapObjectAreaPolygonChannel/messages/sendMapObjectAreaPolygon.message"
        }
      ]
    },
    "sendMapObjectAreaCircle": {
      "action": "send",
      "channel": {
        "$ref": "#/channels/mapObjectAreaCircleChannel"
      },
      "summary": "Publishes circle area map object",
      "messages": [
        {
          "$ref": "#/channels/mapObjectAreaCircleChannel/messages/sendMapObjectAreaCircle.message"
        }
      ]
    }
  },
  "components": {
    "channelBindings": {
      "MapObjectMqttSettings": {
        "mqtt": {
          "qos": 2,
          "retain": true
        }
      }
    },
    "securitySchemes": {
      "tls": {
        "type": "X509",
        "x-securityScheme": "tls",
        "description": "TLS client certificate for secure connection"
      },
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "user",
        "description": "An API key is required for connecting to the MQTT broker"
      }
    },
    "parameters": {
      "MapObjectBaseTopic": {
        "description": "Base topic path for map objects: {organization}/general/generic/real/c2/target/positions. See MapObjectBaseTopic schema for structure.",
        "location": "$message.payload#/name"
      },
      "Organization": {
        "enum": [
          "waraps",
          "saab",
          "liu"
        ],
        "description": "The organization/owner of the agent."
      }
    },
    "schemas": {
      "MapObjectBaseTopic": {
        "description": "Base topic string for map objects, composed of organization and a fixed path segment.",
        "type": "string",
        "properties": {
          "organization": {
            "enum": [
              "waraps",
              "saab",
              "liu"
            ]
          }
        },
        "required": [
          "organization"
        ],
        "example": "waraps/general/generic/real/c2/target/positions/test-point-P",
        "pattern": "{organization}/general/generic/real/c2/target/positions/{name}-{type}"
      },
      "MapObjectPointPayload": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "value": "test-point-P",
            "example": "test-point-P",
            "description": "Name has to end with -P"
          },
          "type": {
            "type": "string",
            "description": "The type of map object.",
            "example": "point"
          },
          "lat": {
            "$ref": "#/components/schemas/Latitude"
          },
          "lon": {
            "$ref": "#/components/schemas/Longitude"
          },
          "color": {
            "$ref": "#/components/schemas/WebColor"
          }
        },
        "required": [
          "name",
          "type",
          "lat",
          "lon"
        ]
      },
      "MapObjectPathPayload": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "value": "test-route-R",
            "example": "test-route-R",
            "description": "Name has to end with -R"
          },
          "type": {
            "type": "string",
            "description": "The type of map object.",
            "example": "polyline"
          },
          "line": {
            "$ref": "#/components/schemas/Line"
          },
          "color": {
            "$ref": "#/components/schemas/WebColor"
          }
        },
        "required": [
          "name",
          "type",
          "line"
        ]
      },
      "MapObjectAreaPolygonPayload": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "value": "test-area-A",
            "example": "test-area-A",
            "description": "Name has to end with -A"
          },
          "type": {
            "type": "string",
            "description": "The type of map object.",
            "example": "area"
          },
          "area": {
            "$ref": "#/components/schemas/Area"
          },
          "color": {
            "$ref": "#/components/schemas/WebColor"
          }
        },
        "required": [
          "name",
          "type",
          "area"
        ]
      },
      "MapObjectAreaCirclePayload": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "value": "test-area-A",
            "example": "test-area-A",
            "description": "Name has to end with -A"
          },
          "type": {
            "type": "string",
            "description": "The type of map object.",
            "example": "circle"
          },
          "lat": {
            "$ref": "#/components/schemas/Latitude"
          },
          "lon": {
            "$ref": "#/components/schemas/Longitude"
          },
          "radius": {
            "$ref": "#/components/schemas/Radius"
          },
          "color": {
            "$ref": "#/components/schemas/WebColor"
          }
        },
        "required": [
          "name",
          "type",
          "lat",
          "lon",
          "radius"
        ]
      },
      "Line": {
        "type": "array",
        "minItems": 2,
        "description": "An array of latitude and longitude pairs defining a path/route.",
        "items": {
          "$ref": "#/components/schemas/LatLon"
        }
      },
      "Area": {
        "type": "array",
        "minItems": 3,
        "description": "An array of latitude and longitude pairs defining a polygon area.",
        "items": {
          "$ref": "#/components/schemas/LatLon"
        }
      },
      "WebColor": {
        "type": "string",
        "description": "Web color in hex format (#RGB)",
        "format": "color",
        "example": "#FFFFFF"
      },
      "Latitude": {
        "type": "number",
        "description": "WGS84 latitude, seven or more decimals for centimeter precision.",
        "example": 57.7611363,
        "format": "float"
      },
      "Longitude": {
        "type": "number",
        "description": "WGS84 longitude, seven or more decimals for centimeter precision.",
        "example": 16.6805011,
        "format": "float"
      },
      "Altitude": {
        "type": "number",
        "description": "WGS84 altitude in meters (referred to ellipsoid).",
        "example": 47.81,
        "format": "float"
      },
      "LatLon": {
        "type": "array",
        "minItems": 2,
        "maxItems": 2,
        "description": "A pair of latitude and longitude.",
        "items": {
          "type": "number"
        },
        "example": [
          57.7634542,
          16.6817367
        ]
      },
      "Radius": {
        "type": "number",
        "description": "Radius in meters.",
        "example": 98.25,
        "format": "float"
      }
    },
    "messages": {
      "MapObjectAreaPolygonMessage": {
        "name": "map-area-polygon",
        "description": "Message containing a polygon area map object with coordinate pairs.",
        "contentType": "application/json",
        "payload": {
          "$ref": "#/components/schemas/MapObjectAreaPolygonPayload"
        }
      },
      "MapObjectAreaCircleMessage": {
        "name": "map-area-circle",
        "description": "Message containing a circle area map object with center and radius.",
        "contentType": "application/json",
        "payload": {
          "$ref": "#/components/schemas/MapObjectAreaCirclePayload"
        }
      },
      "MapObjectPointMessage": {
        "name": "map-point",
        "description": "Message containing a point map object with coordinates.",
        "contentType": "application/json",
        "payload": {
          "$ref": "#/components/schemas/MapObjectPointPayload"
        }
      },
      "MapObjectPathMessage": {
        "name": "map-path",
        "description": "Message containing a path/route map object with a line of coordinate pairs.",
        "contentType": "application/json",
        "payload": {
          "$ref": "#/components/schemas/MapObjectPathPayload"
        }
      }
    }
  }
}
