{
  "openapi": "3.0.0",
  "info": {
    "version": "2.18.0",
    "title": "Freeboard-SK API",
    "description": "API endpoints exposed by Freeboard-SK to support application functionality and experimental features.",
    "termsOfService": "http://signalk.org/terms/",
    "license": {
      "name": "Apache 2.0",
      "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
    }
  },
  "externalDocs": {
    "url": "http://signalk.org/specification/",
    "description": "Signal K specification."
  },
  "servers": [
    {
      "url": "/"
    }
  ],
  "tags": [
    {
      "name": "Alarms",
      "description": "Standard alarms."
    },
    {
      "name": "Areas",
      "description": "Area alarms."
    }
  ],
  "components": {
    "schemas": {
      "Position": {
        "type": "object",
        "required": [
          "latitude",
          "longitude"
        ],
        "properties": {
          "latitude": {
            "type": "number",
            "format": "float"
          },
          "longitude": {
            "type": "number",
            "format": "float"
          }
        }
      },
      "IsoTime": {
        "type": "string",
        "description": "Date / Time when data values were recorded",
        "pattern": "^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2}(?:\\.\\d*)?)((-(\\d{2}):(\\d{2})|Z)?)$",
        "example": "2022-04-22T05:02:56.484Z"
      },
      "AreaAlarmDef": {
        "type": "object",
        "required": [
          "trigger",
          "geometry"
        ],
        "properties": {
          "geometry": {
            "type": "string",
            "enum": [
              "polygon",
              "circle",
              "region"
            ]
          },
          "trigger": {
            "type": "string",
            "enum": [
              "entry",
              "exit"
            ]
          },
          "coords": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Position"
            },
            "description": "Coordinates of the alarm area. `(required when geometry = 'polygon')`"
          },
          "center": {
            "$ref": "#/components/schemas/Position",
            "description": "Center of circlular area. `(required when geometry = 'circle')`"
          },
          "radius": {
            "type": "number",
            "description": "Circle radius in meters. `(required when geometry = 'circle')`"
          },
          "name": {
            "type": "string"
          }
        }
      }
    },
    "responses": {
      "200OKResponse": {
        "description": "Successful operation",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "description": "Request success response",
              "properties": {
                "state": {
                  "type": "string",
                  "enum": [
                    "COMPLETED"
                  ]
                },
                "statusCode": {
                  "type": "number",
                  "enum": [
                    200
                  ]
                }
              },
              "required": [
                "state",
                "statusCode"
              ]
            }
          }
        }
      },
      "ErrorResponse": {
        "description": "Failed operation",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "description": "Request error response",
              "properties": {
                "state": {
                  "type": "string",
                  "enum": [
                    "FAILED"
                  ]
                },
                "statusCode": {
                  "type": "number",
                  "enum": [
                    404
                  ]
                },
                "message": {
                  "type": "string"
                }
              },
              "required": [
                "state",
                "statusCode",
                "message"
              ]
            }
          }
        }
      }
    },
    "parameters": {
      "AlarmIdParam": {
        "in": "path",
        "required": true,
        "name": "id",
        "description": "Alarm identifier.",
        "schema": {
          "type": "number"
        }
      },
      "AlarmTypeParam": {
        "in": "path",
        "required": true,
        "name": "alarmType",
        "description": "Alarm type.",
        "schema": {
          "type": "string",
          "enum": [
            "mob",
            "fire",
            "sinking",
            "flooding",
            "collision",
            "grounding",
            "listing",
            "adrift",
            "piracy",
            "abandon",
            "aground"
          ]
        }
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      },
      "cookieAuth": {
        "type": "apiKey",
        "in": "cookie",
        "name": "JAUTHENTICATION"
      }
    }
  },
  "security": [
    {
      "cookieAuth": []
    },
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/signalk/v2/api/alarms/area": {
      "post": {
        "tags": [
          "Areas"
        ],
        "summary": "Set Alarm area.",
        "requestBody": {
          "description": "Sets the defined area to monitor for vessel entry /exit.",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AreaAlarmDef"
              }
            }
          }
        },
        "responses": {
          "200ActionResponse": {
            "$ref": "#/components/responses/200OKResponse"
          },
          "default": {
            "$ref": "#/components/responses/ErrorResponse"
          }
        }
      }
    },
    "/signalk/v2/api/alarms/area/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AlarmIdParam"
        }
      ],
      "put": {
        "tags": [
          "Areas"
        ],
        "summary": "Update Alarm area OR Set the `Region` resource with the supplied identifier as the alarm area.",
        "requestBody": {
          "description": "Updates the area details for the supplied area identfier.",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AreaAlarmDef"
              }
            }
          }
        },
        "responses": {
          "200ActionResponse": {
            "$ref": "#/components/responses/200OKResponse"
          },
          "default": {
            "$ref": "#/components/responses/ErrorResponse"
          }
        }
      },
      "delete": {
        "tags": [
          "Areas"
        ],
        "summary": "Clear / cancel Area Alarm.",
        "responses": {
          "200ActionResponse": {
            "$ref": "#/components/responses/200OKResponse"
          },
          "default": {
            "$ref": "#/components/responses/ErrorResponse"
          }
        }
      }
    },
    "/signalk/v2/api/alarms/area/{id}/silence": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AlarmIdParam"
        }
      ],
      "post": {
        "tags": [
          "Areas"
        ],
        "summary": "Silence Area Alarm.",
        "responses": {
          "200ActionResponse": {
            "$ref": "#/components/responses/200OKResponse"
          },
          "default": {
            "$ref": "#/components/responses/ErrorResponse"
          }
        }
      }
    },
    "/signalk/v2/api/alarms/{alarmType}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AlarmTypeParam"
        }
      ],
      "post": {
        "tags": [
          "Alarms"
        ],
        "summary": "Raise Alarm.",
        "requestBody": {
          "description": "Alarm message text.",
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "message": {
                    "type": "string",
                    "description": "Alarm message text.",
                    "example": "Person overboard!"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200ActionResponse": {
            "$ref": "#/components/responses/200OKResponse"
          },
          "default": {
            "$ref": "#/components/responses/ErrorResponse"
          }
        }
      }
    },
    "/signalk/v2/api/alarms/{alarmType}/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AlarmTypeParam"
        },
        {
          "$ref": "#/components/parameters/AlarmIdParam"
        }
      ],
      "delete": {
        "tags": [
          "Alarms"
        ],
        "summary": "Clear / cancel Alarm.",
        "responses": {
          "200ActionResponse": {
            "$ref": "#/components/responses/200OKResponse"
          },
          "default": {
            "$ref": "#/components/responses/ErrorResponse"
          }
        }
      }
    },
    "/signalk/v2/api/alarms/{alarmType}/{id}/silence": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AlarmTypeParam"
        },
        {
          "$ref": "#/components/parameters/AlarmIdParam"
        }
      ],
      "post": {
        "tags": [
          "Alarms"
        ],
        "summary": "Silence Alarm.",
        "responses": {
          "200ActionResponse": {
            "$ref": "#/components/responses/200OKResponse"
          },
          "default": {
            "$ref": "#/components/responses/ErrorResponse"
          }
        }
      }
    }
  }
}