{
    "openapi": "3.0.0",
    "info": {
        "version": "1.0.0",
        "title": "Signal K discovery API",
        "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": "/signalk"
        }
    ],
    "tags": [
        {
            "name": "server",
            "description": "Signal K Server."
        },
        {
            "name": "features",
            "description": "Signal K Server features."
        }
    ],
    "components": {
        "schemas": {
            "DiscoveryData": {
                "type": "object",
                "required": ["endpoints", "server"],
                "properties": {
                    "endpoints": {
                        "type": "object",
                        "properties": {
                            "v1": {
                                "type": "object",
                                "properties": {
                                    "version": {
                                        "type": "string",
                                        "description": "Version of the Signal K API",
                                        "example": "1.1.0"
                                    },
                                    "signalk-http": {
                                        "type": "string",
                                        "description": "Address of the server's http API.",
                                        "example": "http://191.168.1.88:3000/signalk/v1/api/"
                                    },
                                    "signalk-ws": {
                                        "type": "string",
                                        "description": "Address of the server's WebSocket API.",
                                        "example": "http://191.168.1.88:3000/signalk/v1/stream"
                                    },
                                    "signalk-tcp": {
                                        "type": "string",
                                        "description": "Address of the server's Signal K over TCP API.",
                                        "example": "tcp://191.168.1.88:8375"
                                    }
                                }
                            }
                        }
                    },
                    "server": {
                        "type": "object",
                        "required": ["id", "version"],
                        "properties": {
                            "id": {
                                "type": "string",
                                "description": "Id of the server implementation",
                                "example": "signalk-server-node"
                            },
                            "version": {
                                "type": "string",
                                "description": "Server software version"
                            }
                        }
                    }
                }
            },
            "PluginMetaData": {
                "type": "object",
                "required": ["id", "name", "version"],
                "description": "Plugin metadata.",
                "properties": {
                    "id": {
                        "type": "string",
                        "description": "Plugin ID."
                    },
                    "name": {
                        "type": "string",
                        "description": "Plugin name."
                    },
                    "version": {
                        "type": "string",
                        "description": "Plugin verison."
                    }
                }
            },
            "FeaturesModel": {
                "type": "object",
                "required": ["apis", "plugins"],
                "description": "Features response",
                "properties": {
                    "apis": {
                        "type": "array",
                        "description": "Implemented APIs.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "plugins": {
                        "type": "array",
                        "description": "Installed Plugins.",
                        "items": {
                            "$ref": "#/components/schemas/PluginMetaData"
                        }
                    }
                }
            }
        },
        "responses": {
            "DiscoveryResponse": {
                "description": "Discovery response.",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/DiscoveryData"
                        }
                    }
                }
            },
            "200Ok": {
                "description": "OK",
                "content": {
                    "application/json": {
                        "schema": {
                            "type": "object",
                            "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"]
                        }
                    }
                }
            },
            "FeaturesResponse": {
                "description": "Server features response.",
                "content": {
                    "application/json": {
                        "schema": {
                            "description": "Features response.",
                            "$ref": "#/components/schemas/FeaturesModel"
                        }
                    }
                }
            }
        }
    },
    "paths": {
        "/": {
            "get": {
                "tags": ["server"],
                "summary": "Retrieve server version and service endpoints.",
                "description": "Returns data about server's endpoints and versions.",
                "responses": {
                    "200": {
                        "$ref": "#/components/responses/DiscoveryResponse"
                    }
                }
            }
        },
        "/v2/features": {
            "get": {
                "tags": ["features"],
                "parameters": [
                    {
                        "name": "enabled",
                        "in": "query",
                        "description": "Limit results to enabled features.",
                        "required": false,
                        "explode": false,
                        "schema": {
                            "type": "string",
                            "enum": ["enabled", "1", "false", "0"]
                        }
                    }
                ],
                "summary": "Retrieve available server features.",
                "description": "Returns object detailing the available server features.",
                "responses": {
                    "200": {
                        "$ref": "#/components/responses/FeaturesResponse"
                    },
                    "default": {
                        "$ref": "#/components/responses/ErrorResponse"
                    }
                }
            }
        }
    }
}
