{
  "openapi": "3.1.0",
  "info": {
    "title": "EmailTemplate API",
    "description": "API para crear, gestionar y renderizar plantillas de email",
    "version": "1.0.0"
  },
  "paths": {
    "/api/v1/auth/register": {
      "post": {
        "tags": [
          "auth",
          "auth"
        ],
        "summary": "Register",
        "description": "Register a new user with email and password.",
        "operationId": "register_api_v1_auth_register_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UserCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/login": {
      "post": {
        "tags": [
          "auth",
          "auth"
        ],
        "summary": "Login",
        "description": "Login with email and password.",
        "operationId": "login_api_v1_auth_login_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UserLogin"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/logout": {
      "post": {
        "tags": [
          "auth",
          "auth"
        ],
        "summary": "Logout",
        "description": "Logout current user.",
        "operationId": "logout_api_v1_auth_logout_post",
        "parameters": [
          {
            "name": "authorization",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Authorization"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/session": {
      "get": {
        "tags": [
          "auth",
          "auth"
        ],
        "summary": "Get Session",
        "description": "Get current session info.",
        "operationId": "get_session_api_v1_auth_session_get",
        "parameters": [
          {
            "name": "authorization",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Authorization"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/oauth/{provider}": {
      "get": {
        "tags": [
          "auth",
          "auth"
        ],
        "summary": "Oauth Login",
        "description": "Redirect to OAuth provider (Google, GitHub).",
        "operationId": "oauth_login_api_v1_auth_oauth__provider__get",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/OAuthProvider"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/oauth/{provider}/callback": {
      "get": {
        "tags": [
          "auth",
          "auth"
        ],
        "summary": "Oauth Callback",
        "description": "Handle OAuth callback.",
        "operationId": "oauth_callback_api_v1_auth_oauth__provider__callback_get",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/OAuthProvider"
            }
          },
          {
            "name": "code",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Code"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/workspaces": {
      "get": {
        "tags": [
          "auth",
          "auth"
        ],
        "summary": "List Workspaces",
        "description": "List workspaces for current user.",
        "operationId": "list_workspaces_api_v1_auth_workspaces_get",
        "parameters": [
          {
            "name": "authorization",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Authorization"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkspaceInDB"
                  },
                  "title": "Response List Workspaces Api V1 Auth Workspaces Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/templates": {
      "get": {
        "tags": [
          "templates",
          "templates"
        ],
        "summary": "List Templates",
        "description": "List all templates for the user.",
        "operationId": "list_templates_api_v1_templates_get",
        "parameters": [
          {
            "name": "x-api-key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Api-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/templates/starters": {
      "get": {
        "tags": [
          "templates",
          "templates"
        ],
        "summary": "Get Starters",
        "description": "Get starter templates.",
        "operationId": "get_starters_api_v1_templates_starters_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      }
    },
    "/api/v1/health": {
      "get": {
        "tags": [
          "health"
        ],
        "summary": "Health",
        "operationId": "health_api_v1_health_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/storage/{file_id}": {
      "get": {
        "tags": [
          "storage"
        ],
        "summary": "Serve Storage",
        "description": "Serve a file stored in GridFS by its ID.",
        "operationId": "serve_storage_api_v1_storage__file_id__get",
        "parameters": [
          {
            "name": "file_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "File Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/": {
      "get": {
        "tags": [
          "root"
        ],
        "summary": "Read Root",
        "operationId": "read_root__get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      }
    },
    "/{path}": {
      "get": {
        "tags": [
          "root"
        ],
        "summary": "Serve Frontend",
        "operationId": "serve_frontend__path__get",
        "parameters": [
          {
            "name": "path",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Path"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "HealthResponse": {
        "properties": {
          "status": {
            "type": "string",
            "title": "Status"
          },
          "version": {
            "type": "string",
            "title": "Version"
          },
          "timestamp": {
            "type": "string",
            "title": "Timestamp"
          },
          "uptime": {
            "type": "number",
            "title": "Uptime"
          }
        },
        "type": "object",
        "required": [
          "status",
          "version",
          "timestamp",
          "uptime"
        ],
        "title": "HealthResponse"
      },
      "OAuthProvider": {
        "type": "string",
        "enum": [
          "google",
          "github"
        ],
        "title": "OAuthProvider"
      },
      "SessionResponse": {
        "properties": {
          "user": {
            "$ref": "#/components/schemas/UserResponse"
          },
          "workspace": {
            "$ref": "#/components/schemas/WorkspaceInDB"
          },
          "token": {
            "type": "string",
            "title": "Token"
          }
        },
        "type": "object",
        "required": [
          "user",
          "workspace",
          "token"
        ],
        "title": "SessionResponse"
      },
      "TemplateInDB": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 50,
            "minLength": 3,
            "title": "Name"
          },
          "content": {
            "type": "string",
            "maxLength": 102400,
            "title": "Content"
          },
          "engine": {
            "type": "string",
            "title": "Engine",
            "default": "handlebars"
          },
          "variables": {
            "items": {
              "$ref": "#/components/schemas/VariableDefinition"
            },
            "type": "array",
            "title": "Variables",
            "default": []
          },
          "category": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Category"
          },
          "id": {
            "type": "string",
            "title": "Id"
          },
          "version": {
            "type": "integer",
            "title": "Version"
          },
          "created_at": {
            "type": "string",
            "title": "Created At"
          },
          "updated_at": {
            "type": "string",
            "title": "Updated At"
          }
        },
        "type": "object",
        "required": [
          "name",
          "content",
          "id",
          "version",
          "created_at",
          "updated_at"
        ],
        "title": "TemplateInDB"
      },
      "TemplateListResponse": {
        "properties": {
          "templates": {
            "items": {
              "$ref": "#/components/schemas/TemplateInDB"
            },
            "type": "array",
            "title": "Templates"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          },
          "page": {
            "type": "integer",
            "title": "Page"
          },
          "per_page": {
            "type": "integer",
            "title": "Per Page"
          }
        },
        "type": "object",
        "required": [
          "templates",
          "total",
          "page",
          "per_page"
        ],
        "title": "TemplateListResponse"
      },
      "UserCreate": {
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "title": "Email"
          },
          "name": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1,
            "title": "Name"
          },
          "password": {
            "type": "string",
            "maxLength": 100,
            "minLength": 8,
            "title": "Password"
          }
        },
        "type": "object",
        "required": [
          "email",
          "name",
          "password"
        ],
        "title": "UserCreate"
      },
      "UserLogin": {
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "title": "Email"
          },
          "password": {
            "type": "string",
            "title": "Password"
          }
        },
        "type": "object",
        "required": [
          "email",
          "password"
        ],
        "title": "UserLogin"
      },
      "UserResponse": {
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "title": "Email"
          },
          "name": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1,
            "title": "Name"
          },
          "id": {
            "type": "string",
            "title": "Id"
          },
          "tier": {
            "$ref": "#/components/schemas/UserTier"
          },
          "created_at": {
            "type": "string",
            "title": "Created At"
          }
        },
        "type": "object",
        "required": [
          "email",
          "name",
          "id",
          "tier",
          "created_at"
        ],
        "title": "UserResponse"
      },
      "UserTier": {
        "type": "string",
        "enum": [
          "free",
          "pro",
          "team"
        ],
        "title": "UserTier"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          },
          "input": {
            "title": "Input"
          },
          "ctx": {
            "type": "object",
            "title": "Context"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      },
      "VariableDefinition": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 30,
            "pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$",
            "title": "Name"
          },
          "type": {
            "type": "string",
            "title": "Type",
            "default": "string"
          },
          "required": {
            "type": "boolean",
            "title": "Required",
            "default": false
          },
          "default": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Default"
          }
        },
        "type": "object",
        "required": [
          "name"
        ],
        "title": "VariableDefinition"
      },
      "WorkspaceInDB": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1,
            "title": "Name"
          },
          "id": {
            "type": "string",
            "title": "Id"
          },
          "owner_id": {
            "type": "string",
            "title": "Owner Id"
          },
          "created_at": {
            "type": "string",
            "title": "Created At"
          }
        },
        "type": "object",
        "required": [
          "name",
          "id",
          "owner_id",
          "created_at"
        ],
        "title": "WorkspaceInDB"
      }
    }
  },
  "servers": [
    {
      "url": "https://api.emailtemplate.theboomer.dev",
      "description": "Producción"
    }
  ]
}