Enhancements

This commit is contained in:
Joren de Graaf
2026-10-11 20:46:55 +02:00
parent cb12c23732
commit 000ec834b0
26 changed files with 813 additions and 30 deletions
+29
View File
@@ -51,6 +51,20 @@ GROCERIES = {'type': 'object', 'required': ['items'], 'properties': {
UPLOAD = {'type': 'object', 'required': ['image'], 'properties': {
'image': {'type': 'string', 'format': 'binary'}, 'caption': {'type': 'string'},
}}
HYDRATION_MANUAL = {'type': 'object', 'properties': {
'amount_ml': {'type': 'string', 'description': 'Positive decimal, at most 3000 ml'},
'beverage_type': {'type': 'string'},
'recorded_at': {'type': 'string', 'format': 'date-time',
'description': 'Defaults to now; naive values use the user time zone'},
}}
HYDRATION_SETTINGS = {'type': 'object', 'properties': {
'daily_water_goal_ml': {'type': 'integer', 'minimum': 250, 'maximum': 10000},
**{name: {'type': 'boolean'} for name in (
'auto_count_food_drinks', 'include_liquid_foods', 'show_hydration_breakdown',
'allow_manual_hydration_adjustments')},
'hydration_beverage_rules': {'type': 'object', 'description':
'Optional beverage type rules with enabled and factor (0 to 1) keys.'},
}}
@require_GET
@@ -90,6 +104,16 @@ def schema(request):
'/kitchen/consumption/preview/': {'post': operation('Preview package deductions without changing stock', 'inventory:read')},
'/kitchen/consumption/': {'post': operation('Consume stock atomically with Idempotency-Key', 'inventory:write')},
'/kitchen/consumption/{id}/undo/': {'post': operation('Undo a safe consumption transaction', 'inventory:write')},
'/hydration/daily/': {'get': operation('Combined manual and Food Diary fluid totals for a user local date', 'food:read')},
'/hydration/manual/': {'post': operation('Create standalone fluid entry with optional Idempotency-Key', 'food:write', HYDRATION_MANUAL)},
'/hydration/manual/{id}/': {
'patch': operation('Correct own manual fluid entry', 'food:write', HYDRATION_MANUAL),
'delete': operation('Delete own manual fluid entry', 'food:write'),
},
'/hydration/settings/': {
'get': operation('Read hydration settings', 'food:read'),
'patch': operation('Update hydration settings', 'food:write', HYDRATION_SETTINGS),
},
},
}
for path, methods in document['paths'].items():
@@ -106,6 +130,11 @@ def schema(request):
'description': 'Local calendar date; defaults to today in the user time zone.',
'schema': {'type': 'string', 'format': 'date'},
}]
document['paths']['/hydration/daily/']['get']['parameters'] = [{
'name': 'date', 'in': 'query', 'required': False,
'description': 'Local calendar date; defaults to today in the user time zone.',
'schema': {'type': 'string', 'format': 'date'},
}]
document['paths']['/food/products/lookup/']['get']['parameters'] = [
{'name': name, 'in': 'query', 'required': False, 'schema': schema} for name, schema in (
('query', {'type': 'string'}), ('barcode', {'type': 'string'}), ('brand', {'type': 'string'}),