Skip to content

Commit

Permalink
🐛 fix(Item Update): Fix ItemUpdateSchema by adding store_id
Browse files Browse the repository at this point in the history
This is not necessary just for updating, but it is necessary for creating items. Since the item update endpoint may update or create items, the `store_id` is added as an optional field to the `ItemUpdateSchema` so that it can be accepted by the API when a client wants to create an item.
  • Loading branch information
jslvtr committed Apr 5, 2024
1 parent 2fd689b commit 19366be
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,24 @@ def put(self, item_data, item_id):
return item
# highlight-end
```

Our `ItemUpdateSchema` at the moment looks like this:

```python title="schemas.py"
class ItemUpdateSchema(Schema):
name = fields.Str()
price = fields.Float()
```

But since now our update endpoint may create items, we need to change the schema to optionally accept a `store_id`.

When updating an item, `name` or `price` (or both) may be passed, but when creating an item, `name`, `price`, and `store_id` must be passed.

Update the `ItemUpdateSchema` to this:

```python title="schemas.py"
class ItemUpdateSchema(Schema):
name = fields.Str()
price = fields.Float()
store_id = fields.Int()
```

0 comments on commit 19366be

Please sign in to comment.