{
  "openapi": "3.1.0",
  "info": {
    "title": "Super Duper public API",
    "version": "1.0.0",
    "description": "Public app catalogue and support contact API for apps.superduper.nz."
  },
  "servers": [
    { "url": "https://apps.superduper.nz" }
  ],
  "paths": {
    "/api/apps": {
      "get": {
        "operationId": "listApps",
        "summary": "List Super Duper apps",
        "responses": {
          "200": {
            "description": "The public app catalogue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["apps"],
                  "properties": {
                    "apps": {
                      "type": "array",
                      "items": { "$ref": "#/components/schemas/App" }
                    }
                  }
                }
              }
            }
          },
          "405": { "$ref": "#/components/responses/Error" }
        }
      }
    },
    "/api/send": {
      "post": {
        "operationId": "sendSupportMessage",
        "summary": "Send a support message",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["email", "message"],
                "properties": {
                  "name": { "type": "string" },
                  "email": { "type": "string", "format": "email" },
                  "regarding": { "type": "string" },
                  "message": { "type": "string", "minLength": 1 }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The support message was accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": { "id": { "type": "string" } }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/Error" },
          "405": { "$ref": "#/components/responses/Error" },
          "500": { "$ref": "#/components/responses/Error" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "App": {
        "type": "object",
        "required": ["slug", "name", "category", "platform", "tagline", "overview", "url"],
        "properties": {
          "slug": { "type": "string" },
          "name": { "type": "string" },
          "category": { "type": "string" },
          "platform": { "type": "string" },
          "tagline": { "type": "string" },
          "overview": { "type": "string" },
          "url": { "type": "string", "format": "uri" },
          "appStoreUrl": { "type": "string", "format": "uri" }
        }
      },
      "Error": {
        "type": "object",
        "required": ["error"],
        "properties": {
          "error": {
            "type": "object",
            "required": ["code", "message", "hint"],
            "properties": {
              "code": { "type": "string" },
              "message": { "type": "string" },
              "hint": { "type": "string" }
            }
          }
        }
      }
    },
    "responses": {
      "Error": {
        "description": "A machine-readable error.",
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/Error" }
          }
        }
      }
    }
  }
}
