Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/NicolasMPP/restorante-springboot/llms.txt

Use this file to discover all available pages before exploring further.

This endpoint updates an existing food item and its associated recipe in a single transactional call. It accepts the same AlimentoCompletoRequest body as the create endpoint. Changing the tipo (food category) is fully supported: because Hibernate does not modify the JPA single-table inheritance discriminator column on a regular merge, Restorante issues a native SQL UPDATE on the tipo_alimento column when the type differs from the current value. If the food item had no recipe at the time of the update, a new Receta is created automatically. If a recipe already exists, its name, process description, chef, and full ingredient list are replaced.

Endpoint

PUT /api/menu/{menuId}/alimento-completo/{alimentoId}

Path parameters

menuId
integer
required
The primary key of the menu that contains the food item. Provided for routing context — the update operates on the food item directly.
alimentoId
integer
required
The primary key of the food item to update.

Request body

Content-Type: application/json — same AlimentoCompletoRequest DTO used by the create endpoint.
nombreAlimento
string
required
Updated display name of the food item. Maximum 100 characters.
precio
number
required
Updated price of the food item as a decimal value. Stored as DECIMAL(10,2).
tipo
string
required
Updated food category. If the value differs from the current discriminator value in the database, the server issues a native SQL UPDATE on the tipo_alimento column within the same transaction. Accepted values:
  • PLATO_FUERTE
  • POSTRE
  • BEBIDA
  • ADICIONAL
  • GENERAL
nombreReceta
string
required
Updated name for the recipe. If the food item had no recipe, a new one is created with this name.
descripcionProceso
string
Updated preparation process description stored on the Receta entity.
chefCedula
string
required
The cédula of the chef to assign as recipe owner. Looked up by exact match. Returns 400 if not found.
ingredientesDescripciones
string[]
The complete new list of ingredient descriptions. The existing ingredient associations on the recipe are cleared and fully replaced with this list. Each string is matched against the descripcion field of existing Ingrediente records — non-matching strings are silently skipped.

Update behaviour

The service applies changes in the following sequence:
  1. Looks up the Alimento by alimentoId — returns 400 if not found.
  2. Saves the updated nombre and precio fields.
  3. Compares the requested tipo with the current discriminator value. If they differ, runs a native SQL update on tipo_alimento.
  4. Looks up the chef by chefCedula — returns 400 if not found.
  5. If the food item has an existing Receta: updates nombreReceta, descripcionProceso, and chef; clears the ingredient list and re-populates it from ingredientesDescripciones.
  6. If the food item has no Receta: creates a new one with the provided fields and links it to the food item.

Responses

StatusBodyDescription
200 OK"Alimento actualizado correctamente"All fields were updated successfully.
400 Bad Request"No se pudo actualizar el alimento"The food item or the chef could not be found, or an unexpected error occurred.

Example request

curl -X PUT http://localhost:8080/api/menu/1/alimento-completo/2 \
  -H "Content-Type: application/json" \
  -d '{
    "nombreAlimento": "Bistec Angus 400g",
    "precio": 28.00,
    "tipo": "PLATO_FUERTE",
    "nombreReceta": "Bistec Premium",
    "descripcionProceso": "Sazonar con sal gruesa. Parrilla a fuego alto, 5 min por lado.",
    "chefCedula": "2345678901",
    "ingredientesDescripciones": ["Carne Vacuna", "Sal", "Pimienta", "Aceite de Oliva"]
  }'

Example responses

Success — 200 OK
Alimento actualizado correctamente
Failure — 400 Bad Request
No se pudo actualizar el alimento

Build docs developers (and LLMs) love