{ "openapi": "3.0.0", "info": { "title": "API de Hotel", "version": "1.0.0", "description": "API para gestionar usuarios, habitaciones y reservaciones en el hotel" }, "components": { "securitySchemes": { "bearerAuth": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" } } }, "servers": [ { "url": "https://backendconpostman.onrender.com" } ], "paths": { "/api/usuarios/register": { "post": { "summary": "Registrar un nuevo usuario", "tags": ["Usuarios"], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["username", "email", "password"], "properties": { "username": { "type": "string" }, "email": { "type": "string", "format": "email" }, "password": { "type": "string" } } } } } }, "responses": { "201": { "description": "Usuario creado exitosamente" }, "400": { "description": "El usuario ya existe o datos inválidos" }, "500": { "description": "Error al registrar el usuario" } } } }, "/api/usuarios/login": { "post": { "summary": "Iniciar sesión de un usuario", "tags": ["Usuarios"], "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": "string" } } } } } }, "responses": { "200": { "description": "Inicio de sesión exitoso, se devuelve el token", "content": { "application/json": { "schema": { "type": "object", "properties": { "_id": { "type": "string" }, "username": { "type": "string" }, "email": { "type": "string", "format": "email" }, "token": { "type": "string" } } } } } }, "401": { "description": "Credenciales inválidas" }, "500": { "description": "Error al iniciar sesión" } } } }, "/api/habitaciones": { "get": { "summary": "Obtener todas las habitaciones", "tags": ["Habitaciones"], "responses": { "200": { "description": "Lista de habitaciones", "content": { "application/json": { "schema": { "type": "array", "items": { "type": "object", "properties": { "numero": { "type": "integer" }, "tipo": { "type": "string" }, "precio": { "type": "number", "format": "float" }, "disponibilidad": { "type": "boolean" } } } } } } } } }, "post": { "summary": "Crear una nueva habitación", "tags": ["Habitaciones"], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["numero", "tipo", "precio"], "properties": { "numero": { "type": "integer" }, "tipo": { "type": "string" }, "precio": { "type": "number", "format": "float" } } } } } }, "responses": { "201": { "description": "Habitación creada exitosamente" }, "400": { "description": "Datos inválidos" } } } }, "/api/habitaciones/": { "get": { "summary": "Obtener una habitación por número", "tags": ["Habitaciones"], "parameters": [ { "name": "numero", "in": "path", "required": true, "schema": { "type": "integer" } } ], "responses": { "200": { "description": "Detalles de la habitación", "content": { "application/json": { "schema": { "type": "object", "properties": { "numero": { "type": "integer" }, "tipo": { "type": "string" }, "precio": { "type": "number", "format": "float" }, "disponibilidad": { "type": "boolean" } } } } } }, "404": { "description": "Habitación no encontrada" } } }, "put": { "summary": "Actualizar una habitación", "tags": ["Habitaciones"], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "tipo": { "type": "string" }, "precio": { "type": "number", "format": "float" } } } } } }, "responses": { "200": { "description": "Habitación actualizada exitosamente" }, "404": { "description": "Habitación no encontrada" } } }, "delete": { "summary": "Eliminar una habitación", "tags": ["Habitaciones"], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "numero": { "type": "integer" } } } } } }, "responses": { "204": { "description": "Habitación eliminada exitosamente" }, "404": { "description": "Habitación no encontrada" } } } }, "/api/habitaciones/disponibles": { "get": { "summary": "Obtener habitaciones disponibles", "tags": ["Habitaciones"], "responses": { "200": { "description": "Lista de habitaciones disponibles", "content": { "application/json": { "schema": { "type": "array", "items": { "type": "object", "properties": { "numero": { "type": "integer" }, "precio": { "type": "number", "format": "float" } } } } } } }, "500": { "description": "Error al obtener habitaciones disponibles" } } } }, "/api/habitaciones/ocupadas": { "get": { "summary": "Obtener habitaciones ocupadas", "tags": ["Habitaciones"], "responses": { "200": { "description": "Lista de habitaciones ocupadas", "content": { "application/json": { "schema": { "type": "array", "items": { "type": "object", "properties": { "numero": { "type": "integer" }, "tipo": { "type": "string" }, "precio": { "type": "number", "format": "float" }, "disponibilidad": { "type": "boolean" } } } } } } }, "500": { "description": "Error al obtener habitaciones ocupadas" } } } }, "/api/habitaciones/{numero}/checkout": { "put": { "summary": "Realizar check-out de una habitación", "tags": ["Habitaciones"], "parameters": [ { "name": "numero", "in": "path", "required": true, "schema": { "type": "integer" }, "description": "Número de la habitación" } ], "responses": { "200": { "description": "Check-out realizado exitosamente", "content": { "application/json": { "schema": { "type": "object", "properties": { "mensaje": { "type": "string" } } } } } }, "404": { "description": "Habitación no encontrada" }, "500": { "description": "Error al realizar el check-out" } } } }, "/api/reservaciones": { "get": { "summary": "Obtener todas las reservaciones", "tags": ["Reservaciones"], "responses": { "200": { "description": "Lista de reservaciones", "content": { "application/json": { "schema": { "type": "array", "items": { "type": "object", "properties": { "nombre": { "type": "string" }, "apellidos": { "type": "string" }, "telefono": { "type": "string" }, "correo": { "type": "string" }, "noHabitacion": { "type": "integer" }, "diaEntrada": { "type": "string", "format": "date" }, "diaSalida": { "type": "string", "format": "date" }, "horaEntrada": { "type": "string", "format": "time" }, "horaSalida": { "type": "string", "format": "time" }, "costoTotal": { "type": "number", "format": "float" }, "facturacion": { "type": "boolean" } } } } } } } } }, "post": { "summary": "Crear una nueva reservación", "tags": ["Reservaciones"], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["nombre", "apellidos", "telefono", "noHabitacion", "diaEntrada", "diaSalida", "horaEntrada", "horaSalida"], "properties": { "nombre": { "type": "string" }, "apellidos": { "type": "string" }, "telefono": { "type": "string" }, "correo": { "type": "string" }, "noHabitacion": { "type": "integer" }, "diaEntrada": { "type": "string", "format": "date" }, "diaSalida": { "type": "string", "format": "date" }, "horaEntrada": { "type": "string", "format": "time" }, "horaSalida": { "type": "string", "format": "time" }, "facturacion": { "type": "boolean" } } } } } }, "responses": { "201": { "description": "Reservación creada exitosamente" }, "400": { "description": "Datos inválidos" } } } }, "/api/reservaciones/{id}": { "get": { "summary": "Obtener una reservación por ID", "tags": ["Reservaciones"], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Detalles de la reservación", "content": { "application/json": { "schema": { "type": "object", "properties": { "nombre": { "type": "string" }, "apellidos": { "type": "string" }, "telefono": { "type": "string" }, "correo": { "type": "string" }, "noHabitacion": { "type": "integer" }, "diaEntrada": { "type": "string", "format": "date" }, "diaSalida": { "type": "string", "format": "date" }, "horaEntrada": { "type": "string", "format": "time" }, "horaSalida": { "type": "string", "format": "time" }, "costoTotal": { "type": "number", "format": "float" }, "facturacion": { "type": "boolean" } } } } } }, "404": { "description": "Reservación no encontrada" } } }, "delete": { "summary": "Eliminar una reservación", "tags": ["Reservaciones"], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string" } } ], "responses": { "204": { "description": "Reservación eliminada exitosamente" }, "404": { "description": "Reservación no encontrada" } } }, "put": { "summary": "Actualizar una reservación", "tags": ["Reservaciones"], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "nombre": { "type": "string" }, "apellidos": { "type": "string" }, "telefono": { "type": "string" }, "correo": { "type": "string" }, "noHabitacion": { "type": "integer" }, "diaEntrada": { "type": "string", "format": "date" }, "diaSalida": { "type": "string", "format": "date" }, "horaEntrada": { "type": "string", "format": "time" }, "horaSalida": { "type": "string", "format": "time" }, "facturacion": { "type": "boolean" } } } } } }, "responses": { "200": { "description": "Reservación actualizada exitosamente" }, "404": { "description": "Reservación no encontrada" } } } } } }