openapi: '3.0.0' info: title: 'API Keep Notes' version: '1.0.0' description: 'API REST para gestión de notas con colaboradores' servers: - url: 'http://localhost:3000/api/v1' paths: /auth/register: post: tags: - 'auth' summary: 'Registrar nuevo usuario' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/AuthBody' responses: 201: description: 'Usuario creado exitosamente' content: application/json: schema: $ref: '#/components/schemas/AuthResponse' 400: description: 'Error de validación' 409: description: 'Email ya registrado' 500: description: 'Error interno del servidor' /auth/login: post: tags: - 'auth' summary: 'Iniciar sesión' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/AuthBody' responses: 200: description: 'Inicio de sesión exitoso' content: application/json: schema: $ref: '#/components/schemas/AuthResponse' 400: description: 'Credenciales inválidas' 500: description: 'Error interno del servidor' /notes: get: tags: - 'notes' summary: 'Listar notas del usuario' description: 'Obtiene todas las notas del usuario autenticado (propias y compartidas)' security: - bearerAuth: [] responses: 200: description: 'Lista de notas' content: application/json: schema: type: 'object' properties: success: type: 'boolean' data: type: 'array' items: $ref: '#/components/schemas/NoteWithCollaborators' 401: description: 'No autenticado' 500: description: 'Error interno del servidor' post: tags: - 'notes' summary: 'Crear nueva nota' security: - bearerAuth: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateNoteBody' responses: 201: description: 'Nota creada' content: application/json: schema: type: 'object' properties: success: type: 'boolean' data: $ref: '#/components/schemas/Note' 400: description: 'Error de validación' 401: description: 'No autenticado' 500: description: 'Error interno del servidor' /notes/{id}: get: tags: - 'notes' summary: 'Obtener nota por ID' security: - bearerAuth: [] parameters: - name: 'id' in: 'path' required: true schema: type: 'string' responses: 200: description: 'Nota encontrada' content: application/json: schema: type: 'object' properties: success: type: 'boolean' data: $ref: '#/components/schemas/NoteWithCollaborators' 400: description: 'Nota no encontrada o sin acceso' 401: description: 'No autenticado' 500: description: 'Error interno del servidor' put: tags: - 'notes' summary: 'Actualizar nota' description: 'Solo propietario y colaboradores pueden editar' security: - bearerAuth: [] parameters: - name: 'id' in: 'path' required: true schema: type: 'string' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/UpdateNoteBody' responses: 200: description: 'Nota actualizada' content: application/json: schema: type: 'object' properties: success: type: 'boolean' data: $ref: '#/components/schemas/Note' 400: description: 'Error de validación o sin acceso' 401: description: 'No autenticado' 500: description: 'Error interno del servidor' delete: tags: - 'notes' summary: 'Eliminar nota' description: 'Solo propietario puede eliminar' security: - bearerAuth: [] parameters: - name: 'id' in: 'path' required: true schema: type: 'string' responses: 200: description: 'Nota eliminada' content: application/json: schema: type: 'object' properties: success: type: 'boolean' message: type: 'string' 400: description: 'Sin permisos para eliminar' 401: description: 'No autenticado' 500: description: 'Error interno del servidor' /notes/{id}/share: post: tags: - 'notes' summary: 'Compartir nota con otro usuario' description: 'Solo propietario puede compartir notas' security: - bearerAuth: [] parameters: - name: 'id' in: 'path' required: true schema: type: 'string' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ShareNoteBody' responses: 200: description: 'Nota compartida' content: application/json: schema: type: 'object' properties: success: type: 'boolean' message: type: 'string' 400: description: 'Error de validación o sin permisos' 401: description: 'No autenticado' 500: description: 'Error interno del servidor' components: securitySchemes: bearerAuth: type: 'http' scheme: 'bearer' bearerFormat: 'JWT' schemas: AuthBody: type: 'object' required: - 'email' - 'password' properties: email: type: 'string' format: 'email' example: 'user@example.com' password: type: 'string' example: '123456' AuthResponse: type: 'object' properties: success: type: 'boolean' data: type: 'object' properties: token: type: 'string' example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' Note: type: 'object' properties: id: type: 'string' example: '123e4567-e89b-12d3-a456-426614174000' title: type: 'string' example: 'Mi primera nota' content: type: 'string' example: 'Contenido de la nota' createdAt: type: 'string' format: 'date-time' updatedAt: type: 'string' format: 'date-time' ownerId: type: 'string' NoteWithCollaborators: allOf: - $ref: '#/components/schemas/Note' - type: 'object' properties: collaborators: type: 'array' items: type: 'object' properties: id: type: 'string' email: type: 'string' CreateNoteBody: type: 'object' required: - 'title' properties: title: type: 'string' example: 'Nueva nota' content: type: 'string' example: 'Contenido opcional' UpdateNoteBody: type: 'object' properties: title: type: 'string' example: 'Título actualizado' content: type: 'string' example: 'Contenido actualizado' ShareNoteBody: type: 'object' required: - 'email' properties: email: type: 'string' format: 'email' example: 'colaborador@example.com'