{
  "openapi": "3.1.0",
  "info": {
    "title": "Sleek API",
    "description": "Public REST API for sleek, a beautiful habit and task tracker.",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://sleek-tracker.vercel.app/api/v1",
      "description": "v1 API"
    }
  ],
  "security": [
    {
      "OAuth2": ["read:habits", "write:habits"]
    }
  ],
  "paths": {
    "/habits": {
      "get": {
        "operationId": "getHabits",
        "summary": "List habits",
        "description": "Retrieve a list of all habits for the authenticated user.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of habits to return",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": { "type": "string" },
                      "name": { "type": "string" },
                      "color": { "type": "string" }
                    },
                    "required": ["id", "name", "color"]
                  }
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/ErrorResponse"
          },
          "5XX": {
            "$ref": "#/components/responses/ErrorResponse"
          }
        }
      }
    },
    "/stats": {
      "get": {
        "operationId": "getStats",
        "summary": "Get user statistics",
        "description": "Retrieve statistics for the authenticated user.",
        "parameters": [
          {
            "name": "period",
            "in": "query",
            "description": "Time period for stats (e.g., 'weekly', 'monthly')",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["weekly", "monthly", "all_time"],
              "default": "weekly"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "totalHabits": { "type": "integer" },
                    "completedToday": { "type": "integer" }
                  },
                  "required": ["totalHabits", "completedToday"]
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/ErrorResponse"
          },
          "5XX": {
            "$ref": "#/components/responses/ErrorResponse"
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "ErrorResponse": {
        "description": "Standardized error response",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorProblem"
            }
          }
        }
      }
    },
    "schemas": {
      "ErrorProblem": {
        "type": "object",
        "properties": {
          "type": { "type": "string" },
          "title": { "type": "string" },
          "status": { "type": "integer" },
          "detail": { "type": "string" },
          "instance": { "type": "string" }
        },
        "required": ["type", "title", "status"]
      }
    },
    "securitySchemes": {
      "OAuth2": {
        "type": "oauth2",
        "description": "OAuth 2.0 authentication",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://sleek-tracker.vercel.app/api/auth/oauth/authorize",
            "tokenUrl": "https://sleek-tracker.vercel.app/api/auth/oauth/token",
            "scopes": {
              "read:habits": "Read access to user habits",
              "write:habits": "Write access to user habits"
            }
          }
        }
      }
    }
  }
}
