From 42329c7dda70f1cb9fdc5d888e000d0177e66c2a Mon Sep 17 00:00:00 2001 From: Monique Rio Date: Mon, 7 Oct 2024 16:05:40 +0000 Subject: [PATCH] adds basic metadata and example barcode --- aim/digifeeds/database/main.py | 7 ++++++- aim/digifeeds/database/schemas.py | 24 ++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/aim/digifeeds/database/main.py b/aim/digifeeds/database/main.py index c0e9ce2..6afe49b 100644 --- a/aim/digifeeds/database/main.py +++ b/aim/digifeeds/database/main.py @@ -11,7 +11,12 @@ engine = create_engine(S.mysql_database) SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) -app = FastAPI() + +description = """ +The Digifeeds API enables tracking of images sent to HathiTrust and Google +through the digifeeds workflow +""" +app = FastAPI(title="Digifeeds", description=description) # Dependency diff --git a/aim/digifeeds/database/schemas.py b/aim/digifeeds/database/schemas.py index f2ec084..1ca4e9d 100644 --- a/aim/digifeeds/database/schemas.py +++ b/aim/digifeeds/database/schemas.py @@ -1,6 +1,7 @@ from pydantic import BaseModel, Field, ConfigDict from datetime import datetime + class ItemStatus(BaseModel): name: str = Field(alias="status_name") description: str = Field(alias="status_description") @@ -8,23 +9,42 @@ class ItemStatus(BaseModel): model_config = ConfigDict(populate_by_name=True, from_attributes=True) + class ItemBase(BaseModel): model_config = ConfigDict(populate_by_name=True, from_attributes=True) barcode: str = Field(alias="item_barcode") + class Item(ItemBase): created_at: datetime statuses: list[ItemStatus] = [] + model_config = ConfigDict( + json_schema_extra={ + "examples": [ + { + "barcode": "39015040218748", + "created_at": "2024-09-25T17:12:39", + "statuses": [ + { + "name": "in_zephir", + "description": "Item is in zephir", + "created_at": "2024-09-25T17:13:28", + } + ], + } + ] + } + ) + class ItemCreate(ItemBase): pass + class StatusBase(BaseModel): name: str class Status(StatusBase): description: str - -