latest changes

This commit is contained in:
Joren de Graaf
2026-10-17 11:38:57 +02:00
parent 86e3afaca7
commit 76c76bc281
31 changed files with 4562 additions and 41 deletions
+23 -1
View File
@@ -48,6 +48,17 @@ GROCERIES = {'type': 'object', 'required': ['items'], 'properties': {
'items': {'type': 'array', 'minItems': 1, 'maxItems': 20, 'items': {'type': 'object'}},
'create_missing_products': {'type': 'boolean'},
}}
BULK_INVENTORY_UPDATE = {'type': 'object', 'required': ['items'], 'properties': {
'items': {'type': 'array', 'minItems': 1, 'maxItems': 20, 'items': {'type': 'object',
'required': ['item_id', 'changes'], 'properties': {'item_id': {'type': 'string', 'format': 'uuid'},
'changes': INVENTORY, 'expected_updated_at': {'type': 'string', 'format': 'date-time'}}}},
'dry_run': {'type': 'boolean', 'default': True}, 'atomic': {'type': 'boolean', 'default': False},
}}
BULK_INVENTORY_DELETE = {'type': 'object', 'required': ['item_ids'], 'properties': {
'item_ids': {'type': 'array', 'minItems': 1, 'maxItems': 20, 'items': {'type': 'string', 'format': 'uuid'}},
'dry_run': {'type': 'boolean', 'default': True}, 'confirm': {'type': 'boolean', 'default': False},
'atomic': {'type': 'boolean', 'default': False},
}}
UPLOAD = {'type': 'object', 'required': ['image'], 'properties': {
'image': {'type': 'string', 'format': 'binary'}, 'caption': {'type': 'string'},
}}
@@ -123,6 +134,10 @@ def schema(request):
},
'/kitchen/import-groceries/': {'post': operation('Import up to 20 groceries with per-item results',
'inventory:write + food:write', GROCERIES)},
'/kitchen/bulk-update/': {'post': operation('Preview or update up to 20 inventory items; execution requires Idempotency-Key',
'inventory:write', BULK_INVENTORY_UPDATE)},
'/kitchen/bulk-delete/': {'post': operation('Preview or archive up to 20 inventory items; execution requires confirm and Idempotency-Key',
'inventory:write', BULK_INVENTORY_DELETE)},
'/kitchen/items/{id}/': {
'get': operation('Read own inventory item', 'inventory:read'),
'patch': operation('Update own inventory item', 'inventory:write', INVENTORY),
@@ -191,7 +206,8 @@ def schema(request):
'schema': {'type': 'integer', 'minimum': 1}})
if 'post' in methods:
methods['post']['responses']['201'] = methods['post']['responses'].pop('200')
for path in ('/kitchen/consumption/preview/', '/kitchen/consumption/',
for path in ('/kitchen/bulk-update/', '/kitchen/bulk-delete/',
'/kitchen/consumption/preview/', '/kitchen/consumption/',
'/kitchen/consumption/{id}/undo/', '/recipes/{id}/stock/preview/',
'/recipes/{id}/stock/confirm/', '/recipes/stock-use/{id}/undo/'):
document['paths'][path]['post']['responses']['200'] = document['paths'][path]['post']['responses'].pop('201')
@@ -215,6 +231,12 @@ def schema(request):
'name': 'Idempotency-Key', 'in': 'header', 'required': True,
'schema': {'type': 'string', 'maxLength': 128},
}]
for path in ('/kitchen/bulk-update/', '/kitchen/bulk-delete/'):
document['paths'][path]['post']['parameters'] = [{
'name': 'Idempotency-Key', 'in': 'header', 'required': False,
'description': 'Required when dry_run is false.',
'schema': {'type': 'string', 'maxLength': 128},
}]
document['paths']['/recipes/{id}/log/']['post']['parameters'] = [{
'name': 'Idempotency-Key', 'in': 'header', 'required': True,
'schema': {'type': 'string', 'maxLength': 128},