184 lines
6.4 KiB
JSON
184 lines
6.4 KiB
JSON
{
|
|
"paths": {
|
|
"/auth/register": {
|
|
"post": {
|
|
"tags": ["Auth"],
|
|
"summary": "Register a new user",
|
|
"description": "Creates a new user account with email and password. A default calendar is automatically created. Returns the user profile along with access and refresh tokens.",
|
|
"operationId": "registerUser",
|
|
"security": [],
|
|
"requestBody": {
|
|
"required": true,
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"required": ["email", "password"],
|
|
"properties": {
|
|
"email": { "type": "string", "format": "email", "example": "user@example.com" },
|
|
"password": { "type": "string", "minLength": 10, "example": "securepassword123" },
|
|
"timezone": { "type": "string", "example": "America/Asuncion", "description": "IANA timezone name, defaults to UTC" }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"responses": {
|
|
"200": {
|
|
"description": "User registered successfully",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"required": ["user", "access_token", "refresh_token"],
|
|
"properties": {
|
|
"user": { "$ref": "#/components/schemas/User" },
|
|
"access_token": { "type": "string" },
|
|
"refresh_token": { "type": "string" }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"400": { "description": "Validation error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
|
|
"409": { "description": "Email already exists", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
|
|
}
|
|
}
|
|
},
|
|
"/auth/login": {
|
|
"post": {
|
|
"tags": ["Auth"],
|
|
"summary": "Login with credentials",
|
|
"description": "Authenticates a user with email and password. Returns the user profile along with access and refresh tokens.",
|
|
"operationId": "loginUser",
|
|
"security": [],
|
|
"requestBody": {
|
|
"required": true,
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"required": ["email", "password"],
|
|
"properties": {
|
|
"email": { "type": "string", "format": "email", "example": "user@example.com" },
|
|
"password": { "type": "string", "example": "securepassword123" }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"responses": {
|
|
"200": {
|
|
"description": "Login successful",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"required": ["user", "access_token", "refresh_token"],
|
|
"properties": {
|
|
"user": { "$ref": "#/components/schemas/User" },
|
|
"access_token": { "type": "string" },
|
|
"refresh_token": { "type": "string" }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"401": { "description": "Invalid credentials", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
|
|
}
|
|
}
|
|
},
|
|
"/auth/refresh": {
|
|
"post": {
|
|
"tags": ["Auth"],
|
|
"summary": "Refresh access token",
|
|
"description": "Exchanges a valid refresh token for a new access/refresh token pair.",
|
|
"operationId": "refreshToken",
|
|
"security": [],
|
|
"requestBody": {
|
|
"required": true,
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"required": ["refresh_token"],
|
|
"properties": {
|
|
"refresh_token": { "type": "string" }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"responses": {
|
|
"200": {
|
|
"description": "Tokens refreshed",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"required": ["access_token", "refresh_token"],
|
|
"properties": {
|
|
"access_token": { "type": "string" },
|
|
"refresh_token": { "type": "string" }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"401": { "description": "Invalid or expired refresh token", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
|
|
}
|
|
}
|
|
},
|
|
"/auth/logout": {
|
|
"post": {
|
|
"tags": ["Auth"],
|
|
"summary": "Logout and revoke refresh token",
|
|
"description": "Revokes the provided refresh token, ending the session.",
|
|
"operationId": "logoutUser",
|
|
"requestBody": {
|
|
"required": true,
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"required": ["refresh_token"],
|
|
"properties": {
|
|
"refresh_token": { "type": "string" }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"responses": {
|
|
"200": { "description": "Logged out", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/OkResponse" } } } }
|
|
}
|
|
}
|
|
},
|
|
"/auth/me": {
|
|
"get": {
|
|
"tags": ["Auth"],
|
|
"summary": "Get current authenticated user",
|
|
"description": "Returns the profile of the currently authenticated user.",
|
|
"operationId": "getCurrentUser",
|
|
"responses": {
|
|
"200": {
|
|
"description": "Current user",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"required": ["user"],
|
|
"properties": {
|
|
"user": { "$ref": "#/components/schemas/User" }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|