Data
openapi_first.templates.crud_app.data
In-memory mock data store for CRUD example.
This module intentionally avoids persistence and concurrency guarantees. It is suitable for demos, tests, and scaffolding only.
It intentionally avoids - persistence - concurrency guarantees - validation - error handling
The implementation is suitable for: - demonstrations - tests - scaffolding and example services
It is explicitly NOT suitable for production use.
This module is not part of the openapi_first library API surface.
Functions
create_item
Create a new item in the data store.
A new integer ID is assigned automatically. No validation is performed on the provided payload.
Parameters
payload : dict
Item attributes excluding the id field.
Returns
dict The newly created item, including its assigned ID.
delete_item
Remove an item from the data store.
This function assumes the item exists and will raise KeyError
if the ID is not present.
Parameters
item_id : int Identifier of the item to delete.
get_item
Retrieve a single item by ID.
This function assumes the item exists and will raise KeyError
if the ID is not present in the store.
Parameters
item_id : int Identifier of the item to retrieve.
Returns
dict The stored item representation.
list_items
Return all items in the data store.
This function performs no filtering, pagination, or sorting. The returned collection reflects the current in-memory state.
Returns
list[dict] A list of item representations.
update_item
Replace an existing item in the data store.
This function overwrites the existing item entirely and does not perform partial updates or validation. If the item does not exist, it will be created implicitly.
Parameters
item_id : int
Identifier of the item to update.
payload : dict
Item attributes excluding the id field.
Returns
dict The updated item representation.