{
  "asyncapi": "3.1.0",
  "id": "urn:waraps.api-map-objects",
  "info": {
    "title": "WARA-PS Map Objects MQTT API",
    "version": "1.1.1",
    "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### Quick Start\nEach map object is published as a single **retained** message (QoS 2) on a topic named after the object itself, so late subscribers immediately see the current set of objects without waiting for a republish. Pick the channel by shape, then suffix the object's `name` to match: `-P` for a point, `-R` for a path/route, `-A` for an area (polygon or circle -- distinguished by the payload's `type` field, not the topic).\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"
        }
      }
    },
    "mapObjectAreaChannel": {
      "address": "{MapObjectBaseTopic}/{name}-A",
      "bindings": {
        "$ref": "#/components/channelBindings/MapObjectMqttSettings"
      },
      "messages": {
        "sendMapObjectAreaPolygon.message": {
          "$ref": "#/components/messages/MapObjectAreaPolygonMessage"
        },
        "sendMapObjectAreaCircle.message": {
          "$ref": "#/components/messages/MapObjectAreaCircleMessage"
        }
      },
      "description": "Sends a polygon or circle area map object. Topic name must end with -A. Both shapes share this topic; which one a message is depends on the payload's `type` field (\"area\" for polygon, \"circle\" for circle).",
      "parameters": {
        "MapObjectBaseTopic": {
          "$ref": "#/components/parameters/MapObjectBaseTopic"
        },
        "name": {
          "description": "Name of the map object (e.g., my-area).",
          "location": "$message.payload#/name"
        }
      }
    }
  },
  "operations": {
    "sendMapObjectPoint": {
      "action": "send",
      "title": "Publishes point map object",
      "channel": {
        "$ref": "#/channels/mapObjectPointChannel"
      },
      "summary": "Publishes point map object",
      "messages": [
        {
          "$ref": "#/channels/mapObjectPointChannel/messages/sendMapObjectPoint.message"
        }
      ]
    },
    "sendMapObjectPath": {
      "action": "send",
      "title": "Publishes path/route map object",
      "channel": {
        "$ref": "#/channels/mapObjectPathChannel"
      },
      "summary": "Publishes path/route map object",
      "messages": [
        {
          "$ref": "#/channels/mapObjectPathChannel/messages/sendMapObjectPath.message"
        }
      ]
    },
    "sendMapObjectAreaPolygon": {
      "action": "send",
      "title": "Publishes polygon area map object",
      "channel": {
        "$ref": "#/channels/mapObjectAreaChannel"
      },
      "summary": "Publishes polygon area map object",
      "messages": [
        {
          "$ref": "#/channels/mapObjectAreaChannel/messages/sendMapObjectAreaPolygon.message"
        }
      ]
    },
    "sendMapObjectAreaCircle": {
      "action": "send",
      "title": "Publishes circle area map object",
      "channel": {
        "$ref": "#/channels/mapObjectAreaChannel"
      },
      "summary": "Publishes circle area map object",
      "messages": [
        {
          "$ref": "#/channels/mapObjectAreaChannel/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. Field role for the variable segment is Organization. See MapObjectBaseTopic schema for structure."
      }
    },
    "schemas": {
      "MapObjectBaseTopic": {
        "description": "Base topic string for map objects, composed of organization and a fixed path segment. Field role for the variable segment is Organization. This is a canonical reference schema documenting the topic pattern; the value itself only ever appears substituted into a channel address, never as a message payload field.",
        "type": "string",
        "example": "waraps/general/generic/real/c2/target/positions",
        "pattern": "^[^/]+\\/general\\/generic\\/real\\/c2\\/target\\/positions$"
      },
      "Organization": {
        "type": "string",
        "description": "The organization/owner of the agent. Open-ended and intentionally not enum-restricted: new organizations may join WARA-PS over time.",
        "examples": [
          "waraps",
          "saab",
          "aiics",
          "fmw",
          "liu"
        ]
      },
      "MapObjectPointPayload": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "example": "test-point-P",
            "description": "Name has to end with -P",
            "pattern": "^.+-P$"
          },
          "type": {
            "type": "string",
            "description": "The type of map object.",
            "const": "point",
            "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",
            "example": "test-route-R",
            "description": "Name has to end with -R",
            "pattern": "^.+-R$"
          },
          "type": {
            "type": "string",
            "description": "The type of map object.",
            "const": "polyline",
            "example": "polyline"
          },
          "line": {
            "$ref": "#/components/schemas/Line"
          },
          "color": {
            "$ref": "#/components/schemas/WebColor"
          }
        },
        "required": [
          "name",
          "type",
          "line"
        ]
      },
      "MapObjectAreaPolygonPayload": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "example": "test-area-A",
            "description": "Name has to end with -A",
            "pattern": "^.+-A$"
          },
          "type": {
            "type": "string",
            "description": "The type of map object.",
            "const": "area",
            "example": "area"
          },
          "area": {
            "$ref": "#/components/schemas/Area"
          },
          "color": {
            "$ref": "#/components/schemas/WebColor"
          }
        },
        "required": [
          "name",
          "type",
          "area"
        ]
      },
      "MapObjectAreaCirclePayload": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "example": "test-area-A",
            "description": "Name has to end with -A",
            "pattern": "^.+-A$"
          },
          "type": {
            "type": "string",
            "description": "The type of map object.",
            "const": "circle",
            "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)",
        "pattern": "^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{3})$",
        "example": "#FFFFFF"
      },
      "Latitude": {
        "type": "number",
        "description": "WGS84 latitude, seven or more decimals for centimeter precision.",
        "example": 57.7611363,
        "minimum": -90,
        "maximum": 90,
        "format": "float"
      },
      "Longitude": {
        "type": "number",
        "description": "WGS84 longitude, seven or more decimals for centimeter precision.",
        "example": 16.6805011,
        "minimum": -180,
        "maximum": 180,
        "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"
        },
        "examples": [
          {
            "name": "test-point-P",
            "summary": "A single point map object",
            "payload": {
              "name": "test-point-P",
              "type": "point",
              "lat": 57.7611363,
              "lon": 16.6805011,
              "color": "#FFFFFF"
            }
          }
        ]
      },
      "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"
        }
      }
    }
  }
}
