{"openapi":"3.0.3","info":{"title":"API Delivery MySQL","version":"1.0.0","description":"Documentacion OpenAPI de la API Express para Swagger."},"servers":[{"url":"http://localhost:3000","description":"Servidor local"},{"url":"http://10.100.247.29:3000","description":"Servidor configurado en server.js"}],"tags":[{"name":"Root"},{"name":"Users"},{"name":"Categories"},{"name":"Products"},{"name":"Address"},{"name":"Orders"},{"name":"Payments"}],"components":{"securitySchemes":{"jwtAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"Enviar el token como `JWT <token>`."}},"schemas":{"ErrorResponse":{"type":"object","properties":{"success":{"type":"boolean","example":false},"message":{"type":"string","example":"Hubo un error al procesar la solicitud"},"error":{"type":"object","nullable":true,"additionalProperties":true}}},"UnauthorizedResponse":{"type":"object","properties":{"success":{"type":"boolean","example":false},"message":{"type":"string","example":"El email no fue encontrado"}}},"SuccessIdResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"message":{"type":"string","example":"Operacion realizada correctamente"},"data":{"type":"string","example":"1"}}},"Role":{"type":"object","properties":{"id":{"type":"string","example":"3"},"name":{"type":"string","example":"CLIENTE"},"image":{"type":"string","nullable":true,"example":"role_client.png"},"route":{"type":"string","nullable":true,"example":"/client/orders"}}},"User":{"type":"object","properties":{"id":{"type":"string","example":"5"},"email":{"type":"string","format":"email","example":"juan.perez@example.com"},"name":{"type":"string","example":"Juan"},"lastname":{"type":"string","example":"Perez"},"phone":{"type":"string","example":"0999999999"},"image":{"type":"string","nullable":true,"example":"https://storage.googleapis.com/bucket/image.jpg"},"notification_token":{"type":"string","nullable":true,"example":"firebase-token"},"roles":{"type":"array","items":{"$ref":"#/components/schemas/Role"}}}},"DeliveryUser":{"type":"object","properties":{"id":{"type":"string","example":"2"},"email":{"type":"string","format":"email","example":"repartidor@example.com"},"name":{"type":"string","example":"Pedro"},"lastname":{"type":"string","example":"Gomez"},"image":{"type":"string","nullable":true,"example":"https://storage.googleapis.com/bucket/image.jpg"},"phone":{"type":"string","example":"0988888888"}}},"UserCreateRequest":{"type":"object","required":["email","name","lastname","phone","password"],"properties":{"email":{"type":"string","format":"email","example":"juan.perez@example.com"},"name":{"type":"string","example":"Juan"},"lastname":{"type":"string","example":"Perez"},"phone":{"type":"string","example":"0999999999"},"image":{"type":"string","nullable":true,"example":null},"password":{"type":"string","format":"password","example":"123456"}}},"UserUpdateRequest":{"type":"object","required":["id","name","lastname","phone"],"properties":{"id":{"type":"integer","example":5},"name":{"type":"string","example":"Juan"},"lastname":{"type":"string","example":"Perez"},"phone":{"type":"string","example":"0999999999"},"image":{"type":"string","nullable":true,"example":null},"session_token":{"type":"string","example":"JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"}}},"UpdateNotificationTokenRequest":{"type":"object","required":["id","token"],"properties":{"id":{"type":"integer","example":5},"token":{"type":"string","example":"firebase-notification-token"}}},"LoginRequest":{"type":"object","required":["email","password"],"properties":{"email":{"type":"string","format":"email","example":"juan.perez@example.com"},"password":{"type":"string","format":"password","example":"123456"}}},"LoginData":{"allOf":[{"$ref":"#/components/schemas/User"},{"type":"object","properties":{"session_token":{"type":"string","example":"JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"}}}]},"LoginResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"message":{"type":"string","example":"El usuario fue autenticado"},"data":{"$ref":"#/components/schemas/LoginData"}}},"UserResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"message":{"type":"string","example":"El usuario se actualizo correctamente"},"data":{"$ref":"#/components/schemas/User"}}},"Address":{"type":"object","properties":{"id":{"type":"string","example":"1"},"address":{"type":"string","example":"Sauces 6 mz 123 villa 4"},"neighborhood":{"type":"string","example":"Sauces"},"lat":{"type":"number","format":"double","example":-2.12345},"lng":{"type":"number","format":"double","example":-79.98765},"id_user":{"type":"string","example":"5"}}},"AddressCreateRequest":{"type":"object","required":["address","neighborhood","lat","lng","id_user"],"properties":{"address":{"type":"string","example":"Sauces 6 mz 123 villa 4"},"neighborhood":{"type":"string","example":"Sauces"},"lat":{"type":"number","format":"double","example":-2.12345},"lng":{"type":"number","format":"double","example":-79.98765},"id_user":{"type":"integer","example":5}}},"Category":{"type":"object","properties":{"id":{"type":"string","example":"1"},"name":{"type":"string","example":"Hamburguesas"},"description":{"type":"string","example":"Comida rapida"}}},"CategoryCreateRequest":{"type":"object","required":["name","description"],"properties":{"name":{"type":"string","example":"Hamburguesas"},"description":{"type":"string","example":"Comida rapida"}}},"Product":{"type":"object","properties":{"id":{"type":"string","example":"10"},"name":{"type":"string","example":"Pizza familiar"},"description":{"type":"string","example":"Pizza con queso"},"price":{"type":"number","format":"double","example":12.5},"image1":{"type":"string","nullable":true,"example":"https://storage.googleapis.com/bucket/image1.jpg"},"image2":{"type":"string","nullable":true,"example":"https://storage.googleapis.com/bucket/image2.jpg"},"image3":{"type":"string","nullable":true,"example":"https://storage.googleapis.com/bucket/image3.jpg"},"id_category":{"type":"string","example":"1"}}},"OrderStatus":{"type":"string","enum":["PAGADO","DESPACHADO","EN CAMINO","ENTREGADO"],"example":"PAGADO"},"OrderUser":{"type":"object","properties":{"id":{"type":"string","nullable":true,"example":"2"},"name":{"type":"string","nullable":true,"example":"Juan"},"lastname":{"type":"string","nullable":true,"example":"Perez"},"image":{"type":"string","nullable":true,"example":"https://storage.googleapis.com/bucket/user.jpg"},"phone":{"type":"string","nullable":true,"example":"0999999999"}}},"OrderProduct":{"type":"object","properties":{"id":{"type":"string","example":"10"},"name":{"type":"string","example":"Pizza"},"description":{"type":"string","example":"Pizza familiar"},"image1":{"type":"string","nullable":true,"example":"pizza1.jpg"},"image2":{"type":"string","nullable":true,"example":"pizza2.jpg"},"image3":{"type":"string","nullable":true,"example":"pizza3.jpg"},"price":{"type":"number","format":"double","example":12.5},"quantity":{"type":"integer","example":2}}},"Order":{"type":"object","properties":{"id":{"type":"string","example":"100"},"id_client":{"type":"string","example":"5"},"id_address":{"type":"string","example":"8"},"id_delivery":{"type":"string","nullable":true,"example":"3"},"status":{"$ref":"#/components/schemas/OrderStatus"},"timestamp":{"type":"integer","format":"int64","example":1717098123456},"lat":{"type":"number","nullable":true,"format":"double","example":-2.12345},"lng":{"type":"number","nullable":true,"format":"double","example":-79.98765},"address":{"$ref":"#/components/schemas/Address"},"client":{"$ref":"#/components/schemas/OrderUser"},"delivery":{"$ref":"#/components/schemas/OrderUser"},"products":{"type":"array","items":{"$ref":"#/components/schemas/OrderProduct"}}}},"OrderCreateProduct":{"type":"object","required":["id","quantity"],"properties":{"id":{"type":"integer","example":10},"quantity":{"type":"integer","example":2}}},"OrderCreateRequest":{"type":"object","required":["id_client","id_address","products"],"properties":{"id_client":{"type":"integer","example":5},"id_address":{"type":"integer","example":8},"products":{"type":"array","items":{"$ref":"#/components/schemas/OrderCreateProduct"}}}},"OrderUpdateToDispatchedRequest":{"type":"object","required":["id","id_delivery"],"properties":{"id":{"type":"integer","example":100},"id_delivery":{"type":"integer","example":3}}},"OrderUpdateIdRequest":{"type":"object","required":["id"],"properties":{"id":{"type":"integer","example":100}}},"OrderUpdateLatLngRequest":{"type":"object","required":["id","lat","lng"],"properties":{"id":{"type":"integer","example":100},"lat":{"type":"number","format":"double","example":-2.12345},"lng":{"type":"number","format":"double","example":-79.98765}}},"PaymentCreateRequest":{"type":"object","required":["token","issuer_id","payment_method_id","transaction_amount","installments","payer","order"],"properties":{"token":{"type":"string","example":"card-token"},"issuer_id":{"type":"string","example":"1"},"payment_method_id":{"type":"string","example":"visa"},"transaction_amount":{"type":"number","format":"double","example":25.5},"installments":{"type":"integer","example":1},"payer":{"type":"object","required":["email","identification"],"properties":{"email":{"type":"string","format":"email","example":"comprador@example.com"},"identification":{"type":"object","required":["type","number"],"properties":{"type":{"type":"string","example":"DNI"},"number":{"type":"string","example":"1234567890"}}}}},"order":{"$ref":"#/components/schemas/OrderCreateRequest"}}},"PaymentResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"message":{"type":"string","example":"La orden se ha creado correctamente"},"data":{"type":"object","additionalProperties":true}}}},"responses":{"Unauthorized":{"description":"No autorizado o credenciales invalidas","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthorizedResponse"}}}},"ServerError":{"description":"Error del servidor o de base de datos","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/":{"get":{"tags":["Root"],"summary":"Ruta raiz del backend","responses":{"200":{"description":"Mensaje de estado del backend","content":{"text/html":{"schema":{"type":"string","example":"Ruta raiz del backend"}}}}}}},"/api/users/findDeliveryMen":{"get":{"tags":["Users"],"summary":"Obtener usuarios repartidores","security":[{"jwtAuth":[]}],"responses":{"201":{"description":"Repartidores encontrados","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/DeliveryUser"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"501":{"$ref":"#/components/responses/ServerError"}}}},"/api/users/create":{"post":{"tags":["Users"],"summary":"Registrar usuario sin imagen","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserCreateRequest"}}}},"responses":{"201":{"description":"Usuario creado correctamente","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessIdResponse"}}}},"501":{"$ref":"#/components/responses/ServerError"}}}},"/api/users/createWithImage":{"post":{"tags":["Users"],"summary":"Registrar usuario con imagen","requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["user"],"properties":{"user":{"type":"string","description":"JSON serializado con los datos del usuario.","example":"{\"email\":\"juan.perez@example.com\",\"name\":\"Juan\",\"lastname\":\"Perez\",\"phone\":\"0999999999\",\"password\":\"123456\"}"},"image":{"type":"array","maxItems":1,"items":{"type":"string","format":"binary"}}}}}}},"responses":{"201":{"description":"Usuario creado correctamente","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"501":{"$ref":"#/components/responses/ServerError"}}}},"/api/users/login":{"post":{"tags":["Users"],"summary":"Iniciar sesion","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginRequest"}}}},"responses":{"201":{"description":"Usuario autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"501":{"$ref":"#/components/responses/ServerError"}}}},"/api/users/update":{"put":{"tags":["Users"],"summary":"Actualizar usuario con imagen","security":[{"jwtAuth":[]}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["user"],"properties":{"user":{"type":"string","example":"{\"id\":5,\"name\":\"Juan\",\"lastname\":\"Perez\",\"phone\":\"0999999999\",\"session_token\":\"JWT token\"}"},"image":{"type":"array","maxItems":1,"items":{"type":"string","format":"binary"}}}}}}},"responses":{"201":{"description":"Usuario actualizado correctamente","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"501":{"$ref":"#/components/responses/ServerError"}}}},"/api/users/updateWithoutImage":{"put":{"tags":["Users"],"summary":"Actualizar usuario sin imagen","security":[{"jwtAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserUpdateRequest"}}}},"responses":{"201":{"description":"Usuario actualizado correctamente","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"501":{"$ref":"#/components/responses/ServerError"}}}},"/api/users/updateNotificationToken":{"put":{"tags":["Users"],"summary":"Actualizar token de notificaciones","security":[{"jwtAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateNotificationTokenRequest"}}}},"responses":{"201":{"description":"Token actualizado correctamente","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessIdResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"501":{"$ref":"#/components/responses/ServerError"}}}},"/api/categories/getAll":{"get":{"tags":["Categories"],"summary":"Obtener todas las categorias","security":[{"jwtAuth":[]}],"responses":{"201":{"description":"Categorias encontradas","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Category"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"501":{"$ref":"#/components/responses/ServerError"}}}},"/api/categories/create":{"post":{"tags":["Categories"],"summary":"Crear categoria","security":[{"jwtAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CategoryCreateRequest"}}}},"responses":{"201":{"description":"Categoria creada correctamente","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessIdResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"501":{"$ref":"#/components/responses/ServerError"}}}},"/api/products/findByCategory/{id_category}":{"get":{"tags":["Products"],"summary":"Obtener productos por categoria","security":[{"jwtAuth":[]}],"parameters":[{"name":"id_category","in":"path","required":true,"schema":{"type":"integer"},"example":1}],"responses":{"201":{"description":"Productos encontrados","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Product"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"501":{"$ref":"#/components/responses/ServerError"}}}},"/api/products/findByNameAndCategory/{id_category}/{name}":{"get":{"tags":["Products"],"summary":"Buscar productos por nombre y categoria","security":[{"jwtAuth":[]}],"parameters":[{"name":"id_category","in":"path","required":true,"schema":{"type":"integer"},"example":1},{"name":"name","in":"path","required":true,"schema":{"type":"string"},"example":"pizza"}],"responses":{"201":{"description":"Productos encontrados","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Product"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"501":{"$ref":"#/components/responses/ServerError"}}}},"/api/products/create":{"post":{"tags":["Products"],"summary":"Crear producto con imagenes","security":[{"jwtAuth":[]}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["product","image"],"properties":{"product":{"type":"string","example":"{\"name\":\"Pizza familiar\",\"description\":\"Pizza con queso\",\"price\":12.5,\"image1\":null,\"image2\":null,\"image3\":null,\"id_category\":1}"},"image":{"type":"array","minItems":1,"maxItems":3,"items":{"type":"string","format":"binary"}}}}}}},"responses":{"201":{"description":"Producto creado correctamente","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessIdResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"501":{"$ref":"#/components/responses/ServerError"}}}},"/api/address/findByUser/{id_user}":{"get":{"tags":["Address"],"summary":"Obtener direcciones por usuario","security":[{"jwtAuth":[]}],"parameters":[{"name":"id_user","in":"path","required":true,"schema":{"type":"integer"},"example":5}],"responses":{"201":{"description":"Direcciones encontradas","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Address"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"501":{"$ref":"#/components/responses/ServerError"}}}},"/api/address/create":{"post":{"tags":["Address"],"summary":"Crear direccion","security":[{"jwtAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddressCreateRequest"}}}},"responses":{"201":{"description":"Direccion creada correctamente","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessIdResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"501":{"$ref":"#/components/responses/ServerError"}}}},"/api/orders/findByStatus/{status}":{"get":{"tags":["Orders"],"summary":"Buscar ordenes por estado","security":[{"jwtAuth":[]}],"parameters":[{"name":"status","in":"path","required":true,"schema":{"$ref":"#/components/schemas/OrderStatus"}}],"responses":{"201":{"description":"Ordenes encontradas","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Order"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"501":{"$ref":"#/components/responses/ServerError"}}}},"/api/orders/findByDeliveryAndStatus/{id_delivery}/{status}":{"get":{"tags":["Orders"],"summary":"Buscar ordenes por repartidor y estado","security":[{"jwtAuth":[]}],"parameters":[{"name":"id_delivery","in":"path","required":true,"schema":{"type":"integer"},"example":3},{"name":"status","in":"path","required":true,"schema":{"$ref":"#/components/schemas/OrderStatus"}}],"responses":{"201":{"description":"Ordenes encontradas","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Order"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"501":{"$ref":"#/components/responses/ServerError"}}}},"/api/orders/findByClientAndStatus/{id_client}/{status}":{"get":{"tags":["Orders"],"summary":"Buscar ordenes por cliente y estado","security":[{"jwtAuth":[]}],"parameters":[{"name":"id_client","in":"path","required":true,"schema":{"type":"integer"},"example":5},{"name":"status","in":"path","required":true,"schema":{"$ref":"#/components/schemas/OrderStatus"}}],"responses":{"201":{"description":"Ordenes encontradas","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Order"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"501":{"$ref":"#/components/responses/ServerError"}}}},"/api/orders/create":{"post":{"tags":["Orders"],"summary":"Crear orden","security":[{"jwtAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderCreateRequest"}}}},"responses":{"201":{"description":"Orden creada correctamente","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessIdResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"501":{"$ref":"#/components/responses/ServerError"}}}},"/api/orders/updateToDispatched":{"put":{"tags":["Orders"],"summary":"Actualizar orden a despachada","security":[{"jwtAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderUpdateToDispatchedRequest"}}}},"responses":{"201":{"description":"Orden actualizada correctamente","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessIdResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"501":{"$ref":"#/components/responses/ServerError"}}}},"/api/orders/updateToOnTheWay":{"put":{"tags":["Orders"],"summary":"Actualizar orden a en camino","security":[{"jwtAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderUpdateIdRequest"}}}},"responses":{"201":{"description":"Orden actualizada correctamente","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessIdResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"501":{"$ref":"#/components/responses/ServerError"}}}},"/api/orders/updateToDelivered":{"put":{"tags":["Orders"],"summary":"Actualizar orden a entregada","security":[{"jwtAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderUpdateIdRequest"}}}},"responses":{"201":{"description":"Orden actualizada correctamente","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessIdResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"501":{"$ref":"#/components/responses/ServerError"}}}},"/api/orders/updateLatLng":{"put":{"tags":["Orders"],"summary":"Actualizar latitud y longitud de la orden","security":[{"jwtAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderUpdateLatLngRequest"}}}},"responses":{"201":{"description":"Coordenadas actualizadas correctamente","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessIdResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"501":{"$ref":"#/components/responses/ServerError"}}}},"/api/payments/create":{"post":{"tags":["Payments"],"summary":"Crear pago en Mercado Pago y registrar orden","security":[{"jwtAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaymentCreateRequest"}}}},"responses":{"201":{"description":"Pago creado y orden registrada correctamente","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaymentResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"501":{"$ref":"#/components/responses/ServerError"}}}}}}