munch-ease-backend/main.py

745 lines
24 KiB
Python
Raw Normal View History

2024-01-13 07:42:23 +00:00
import datetime
2025-10-18 03:26:42 +00:00
import os
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
from typing import Annotated, Dict, List, Optional, Any
2024-01-08 00:45:22 +00:00
2025-10-18 03:26:42 +00:00
import aiosqlite
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
from fastapi import Cookie, Depends, FastAPI, Query, APIRouter, Request
2024-04-25 02:03:30 +00:00
from fastapi.encoders import jsonable_encoder
2025-10-18 03:26:42 +00:00
from fastapi.responses import JSONResponse
from pydantic import BaseModel, Field
2024-01-07 00:33:40 +00:00
2025-10-18 03:26:42 +00:00
import db
import ingredients
import meals
import persons
import products
import recipes
import shopping
2024-01-07 00:33:40 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
from fastapi.routing import APIRoute
from common import ProblemDetails, Page, ApiModel
from settings import settings
from api.deps import get_db, cookie_person, error_response
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
class CamelCaseRoute(APIRoute):
def __init__(self, *args, **kwargs):
kwargs.setdefault("response_model_by_alias", True)
kwargs.setdefault("response_model_exclude_none", True)
super().__init__(*args, **kwargs)
app = FastAPI(title="Doof API", version="1.0.0", description="Doof Backend API")
api_v1 = APIRouter(route_class=CamelCaseRoute)
DATABASE_PATH = settings.database_path
2024-01-07 00:33:40 +00:00
# get_db, cookie_person, and error_response are imported from api.deps
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
# OpenAPI reusable responses for ProblemDetails
def _extend_openapi_with_problem_responses(app: FastAPI) -> None:
# Attach a custom openapi generation that injects reusable responses
original_openapi = app.openapi
def custom_openapi():
spec = original_openapi()
components = spec.setdefault("components", {})
responses = components.setdefault("responses", {})
# Standard ProblemDetails responses
responses.setdefault(
"Problem400",
{
"description": "Bad Request",
"content": {
"application/problem+json": {},
"application/json": {"schema": {"$ref": "#/components/schemas/ProblemDetails"}},
},
},
)
responses.setdefault(
"Problem404",
{
"description": "Not Found",
"content": {
"application/problem+json": {},
"application/json": {"schema": {"$ref": "#/components/schemas/ProblemDetails"}},
},
},
)
responses.setdefault(
"Problem422",
{
"description": "Validation Error",
"content": {
"application/problem+json": {
"schema": {"$ref": "#/components/schemas/ProblemDetails"}
},
# Some clients may still expect FastAPI's default error; keep schema available
"application/json": {
"schema": {"$ref": "#/components/schemas/ProblemDetails"}
},
},
},
)
# Normalize v1 responses to reference reusable ProblemDetails where appropriate
paths = spec.get("paths", {})
for path, ops in paths.items():
if not isinstance(path, str) or not path.startswith("/api/v1/"):
continue
if not isinstance(ops, dict):
continue
for method, op in ops.items():
if not isinstance(op, dict):
continue
resp = op.get("responses")
if not isinstance(resp, dict):
continue
# Map 400/404 to reusable references; ensure 422 exists
if "400" in resp:
resp["400"] = {"$ref": "#/components/responses/Problem400"}
if "404" in resp:
resp["404"] = {"$ref": "#/components/responses/Problem404"}
# Only add 422 if not already present
if "422" not in resp:
resp["422"] = {"$ref": "#/components/responses/Problem422"}
return spec
app.openapi = custom_openapi # type: ignore[assignment]
_extend_openapi_with_problem_responses(app)
class ProductUrl(ApiModel):
2024-01-13 01:54:04 +00:00
url: str
2025-10-18 03:26:42 +00:00
tags: List[str] = Field(default_factory=list)
2024-01-13 01:54:04 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
@api_v1.post(
"/products",
operation_id="createProduct",
tags=["products"],
summary="Create or fetch a product from a URL",
)
2025-10-18 03:26:42 +00:00
async def create_product(
url: ProductUrl, conn: aiosqlite.Connection = Depends(get_db)
) -> Optional[products.Product]:
2024-01-13 07:44:48 +00:00
return await products.get_or_create(conn, url.url, url.tags)
2024-01-13 05:40:10 +00:00
2025-10-18 03:26:42 +00:00
async def load_full_recipe(conn: aiosqlite.Connection, id: int) -> Optional[recipes.Recipe]:
2024-01-13 07:44:48 +00:00
r = await recipes.find_recipe_by_id(conn, id)
2024-01-13 06:59:35 +00:00
if not r:
2024-01-13 07:42:23 +00:00
return None
2024-01-13 06:59:35 +00:00
r.ingredients = []
2024-01-17 07:21:16 +00:00
async for ingredient in ingredients.find_ingredients_by_recipe_id(conn, id):
2024-01-13 06:59:35 +00:00
r.ingredients.append(ingredient)
2025-10-18 03:26:42 +00:00
if r.created_by_id is not None:
r.created_by = await persons.get_by_id(conn, r.created_by_id)
2024-04-25 04:57:39 +00:00
2024-01-13 06:59:35 +00:00
return r
2025-10-18 03:26:42 +00:00
2025-10-18 05:54:35 +00:00
from api import recipes as recipes_router # type: ignore
2024-05-02 12:25:11 +00:00
2025-10-18 03:26:42 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
@api_v1.get(
"/meals/upcoming",
operation_id="getUpcomingMeals",
tags=["meals"],
summary="List upcoming meals in a date range",
)
2025-10-18 03:26:42 +00:00
async def get_upcoming_meals(
date_from: Annotated[datetime.datetime, Query(alias="from")],
to: datetime.datetime,
conn: aiosqlite.Connection = Depends(get_db),
) -> List[meals.Meal]:
2024-01-13 07:42:23 +00:00
result = []
2024-05-25 02:33:41 +00:00
async for meal in meals.find_upcoming_meals_by_date_range(conn, date_from, to):
2024-01-17 11:43:16 +00:00
await meals.load_recipes(conn, meal)
await meals.load_extra_ingredients(conn, meal)
2024-04-30 11:21:59 +00:00
await meals.load_participants(conn, meal)
2024-01-13 07:42:23 +00:00
result.append(meal)
return result
2025-10-18 03:26:42 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
@api_v1.get(
"/meals/{meal_id}",
response_model=None,
operation_id="getMeal",
tags=["meals"],
summary="Get a meal by id",
responses={
404: {
"model": ProblemDetails,
"description": "Meal not found",
"content": {"application/problem+json": {}},
}
},
)
2025-10-18 03:26:42 +00:00
async def get_meal(
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
meal_id: int, conn: aiosqlite.Connection = Depends(get_db), request: Request = None
2025-10-18 03:26:42 +00:00
) -> meals.Meal | JSONResponse:
2024-01-17 10:39:48 +00:00
meal = await meals.find_meal_by_id(conn, meal_id)
if not meal:
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
return error_response(request, 404, "Meal not found")
2024-01-17 10:39:48 +00:00
return meal
2025-10-18 03:26:42 +00:00
2024-05-04 05:06:48 +00:00
def get_duplicates(items: List[meals.Person]) -> set[str]:
2025-10-18 03:26:42 +00:00
seen: set[int] = set()
duplicates: set[str] = set()
2024-05-04 05:06:48 +00:00
for item in items:
if item.id in seen:
duplicates.add(item.name)
seen.add(item.id)
return duplicates
2025-10-18 03:26:42 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
def validate_meal(meal: meals.Meal, request: Optional[Request] = None) -> Optional[JSONResponse]:
2024-04-25 04:57:39 +00:00
if not meal.chefs:
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
return error_response(request, 400, "Meal must have at least one chef")
2025-10-18 03:26:42 +00:00
2024-01-13 07:42:23 +00:00
if not meal.cleanup:
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
return error_response(request, 400, "Meal must have at least one cleanup person")
2025-10-18 03:26:42 +00:00
2024-01-13 07:42:23 +00:00
if not meal.consumers:
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
return error_response(request, 400, "Meal must have at least one consumer")
2025-10-18 03:26:42 +00:00
2024-01-17 07:21:16 +00:00
if len(meal.recipes) == 0 and len(meal.extra_ingredients) == 0:
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
return error_response(request, 400, "Meal must have at least one recipe or ingredient")
2025-10-18 03:26:42 +00:00
2024-05-04 05:06:48 +00:00
duplicates = get_duplicates(meal.chefs)
if duplicates:
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
return error_response(request, 400, f'Duplicate chef: {", ".join(duplicates)}')
2025-10-18 03:26:42 +00:00
2024-05-04 05:06:48 +00:00
duplicates = get_duplicates(meal.cleanup)
if duplicates:
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
return error_response(request, 400, f'Duplicate cleanup person: {", ".join(duplicates)}')
2025-10-18 03:26:42 +00:00
2024-05-04 05:06:48 +00:00
duplicates = get_duplicates(meal.consumers)
if duplicates:
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
return error_response(request, 400, f'Duplicate consumer: {", ".join(duplicates)}')
zero_servings = [r for r in meal.recipes if r.servings == 0]
if zero_servings:
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
return error_response(request, 400, "Recipe servings must be greater than 0")
2025-10-18 03:26:42 +00:00
2024-05-04 05:06:48 +00:00
return None
2025-10-18 03:26:42 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
@api_v1.post(
"/meals",
response_model=None,
operation_id="createMeal",
tags=["meals"],
summary="Create a new meal",
responses={
400: {
"model": ProblemDetails,
"description": "Validation error",
"content": {"application/problem+json": {}},
}
},
)
2025-10-18 03:26:42 +00:00
async def create_meal(
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
meal: meals.Meal, conn: aiosqlite.Connection = Depends(get_db), request: Request = None
2025-10-18 03:26:42 +00:00
) -> meals.Meal | JSONResponse:
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
validation_response = validate_meal(meal, request)
2024-05-04 05:06:48 +00:00
if validation_response:
return validation_response
2024-01-17 07:21:16 +00:00
2024-01-13 07:42:23 +00:00
await meals.insert_meal(conn, meal)
await conn.commit()
2024-01-13 08:44:07 +00:00
return meal
2025-10-18 03:26:42 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
@api_v1.put(
"/meals/{meal_id}",
response_model=None,
operation_id="updateMeal",
tags=["meals"],
summary="Update an existing meal",
responses={
400: {
"model": ProblemDetails,
"description": "Validation error",
"content": {"application/problem+json": {}},
},
404: {
"model": ProblemDetails,
"description": "Meal not found",
"content": {"application/problem+json": {}},
},
},
)
2025-10-18 03:26:42 +00:00
async def update_meal(
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
meal_id: int, meal: meals.Meal, conn: aiosqlite.Connection = Depends(get_db), request: Request = None
2025-10-18 03:26:42 +00:00
) -> meals.Meal | JSONResponse:
2024-05-02 11:20:52 +00:00
if meal.id != meal_id:
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
return error_response(request, 400, "Meal ID in URL does not match meal ID in body")
2025-10-18 03:26:42 +00:00
2024-05-02 11:20:52 +00:00
existing = await meals.find_meal_by_id(conn, meal_id)
if not existing:
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
return error_response(request, 404, "Meal not found")
2025-10-18 03:26:42 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
validation_response = validate_meal(meal, request)
2024-05-04 05:06:48 +00:00
if validation_response:
return validation_response
2024-05-02 11:20:52 +00:00
await meals.update_meal(conn, meal)
await conn.commit()
return await get_meal(meal_id, conn)
2025-10-18 03:26:42 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
@api_v1.post(
"/meals/{meal_id}/consumed",
response_model=None,
operation_id="markMealConsumed",
tags=["meals"],
summary="Mark a meal as consumed",
responses={
400: {
"model": ProblemDetails,
"description": "Validation error",
"content": {"application/problem+json": {}},
},
404: {
"model": ProblemDetails,
"description": "Meal not found",
"content": {"application/problem+json": {}},
},
},
)
2025-10-18 03:26:42 +00:00
async def mark_consumed(
meal_id: int,
consumed_date: Optional[datetime.datetime] = None,
conn: aiosqlite.Connection = Depends(get_db),
person: persons.Person = Depends(cookie_person),
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
request: Request = None,
2025-10-18 03:26:42 +00:00
) -> meals.Meal | JSONResponse:
2024-10-14 05:59:05 +00:00
if consumed_date and not consumed_date.tzinfo:
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
return error_response(request, 400, "Consumed date must include timezone")
2025-10-18 03:26:42 +00:00
2024-05-27 11:55:47 +00:00
meal = await meals.find_meal_by_id(conn, meal_id)
2024-05-25 02:33:41 +00:00
if not meal:
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
return error_response(request, 404, "Meal not found")
2024-05-25 02:33:41 +00:00
2024-10-14 05:59:05 +00:00
await meals.mark_consumed(conn, meal, consumed_date or datetime.datetime.now().astimezone())
await shopping.remove_request(conn, person, meal=meal)
2025-10-18 03:26:42 +00:00
2024-05-25 02:33:41 +00:00
await conn.commit()
return meal
2025-10-18 03:26:42 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
@api_v1.delete(
"/meals/{meal_id}",
response_model=None,
operation_id="deleteMeal",
tags=["meals"],
summary="Delete a meal",
responses={
404: {
"model": ProblemDetails,
"description": "Meal not found",
"content": {"application/problem+json": {}},
}
},
)
2025-10-18 03:26:42 +00:00
async def delete_meal(
meal_id: int,
conn: aiosqlite.Connection = Depends(get_db),
person: persons.Person = Depends(cookie_person),
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
request: Request = None,
2025-10-18 03:26:42 +00:00
) -> meals.Meal | JSONResponse:
2024-01-17 11:43:16 +00:00
meal = await meals.find_meal_by_id(conn, meal_id)
if not meal:
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
return error_response(request, 404, "Meal not found")
2024-01-17 11:43:16 +00:00
await shopping.remove_request(conn, person, meal=meal)
2024-01-17 11:43:16 +00:00
await meals.delete_meal(conn, meal.id)
2024-10-13 08:31:37 +00:00
2024-01-17 11:43:16 +00:00
await conn.commit()
return meal
2024-01-17 10:39:48 +00:00
2025-10-18 06:05:48 +00:00
from api import meals as meals_router # type: ignore
app.include_router(meals_router.router, prefix="/api/v1", tags=["v1"]) # extracted
2025-10-18 03:26:42 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
class CurrentShoppingList(ApiModel):
outstanding_items: List[shopping.ShoppingListItem]
requested_meals: List[shopping.ShoppingListItem]
2025-10-18 03:26:42 +00:00
purchased_items: List[shopping.ShoppingListItem] = Field(default_factory=list)
ingredients_lookup: Dict[int, ingredients.Ingredient] = Field(default_factory=dict)
meals_lookup: Dict[int, meals.Meal] = Field(default_factory=dict)
shopping_list_lookup: Dict[int, shopping.ShoppingList] = Field(default_factory=dict)
recipes_lookup: Dict[int, recipes.Recipe] = Field(default_factory=dict)
2024-05-18 07:05:01 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
@api_v1.get(
"/shopping/current",
response_model=CurrentShoppingList,
operation_id="getCurrentShoppingList",
tags=["shopping"],
summary="Get the current aggregated shopping list",
)
2025-10-18 03:26:42 +00:00
async def get_current_shopping_list(
conn: aiosqlite.Connection = Depends(get_db),
) -> CurrentShoppingList:
(
outstanding_requests,
purchased_requests,
meal_requests,
meals_lookup,
recipes_lookup,
ingredients_lookup,
) = await shopping.get_outstanding_requests(conn)
other_shopping_list_ids = {item.list_id for item in purchased_requests}
2025-10-18 03:26:42 +00:00
shopping_list_lookup = {}
for list_id in other_shopping_list_ids:
if list_id is not None:
sl = await shopping.load_shopping_list(conn, list_id)
if sl is not None:
shopping_list_lookup[list_id] = sl
# Add any additional items from shopping lists to the existing lookups
additional_items = [item for sl in shopping_list_lookup.values() for item in sl.items]
if additional_items:
2025-10-18 03:26:42 +00:00
await shopping.to_lookups(
conn, additional_items, meals_lookup, recipes_lookup, ingredients_lookup
)
return CurrentShoppingList(
outstanding_items=outstanding_requests,
requested_meals=meal_requests,
purchased_items=purchased_requests,
meals_lookup=meals_lookup,
shopping_list_lookup=shopping_list_lookup,
ingredients_lookup=ingredients_lookup,
2025-10-18 03:26:42 +00:00
recipes_lookup=recipes_lookup,
)
2025-10-18 03:26:42 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
class PurchasedShoppingList(ApiModel):
list: shopping.ShoppingList
2025-10-18 03:26:42 +00:00
meals_lookup: Dict[int, meals.Meal] = Field(default_factory=dict)
ingredients_lookup: Dict[int, ingredients.Ingredient] = Field(default_factory=dict)
recipes_lookup: Dict[int, recipes.Recipe] = Field(default_factory=dict)
2024-05-19 03:43:06 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
@api_v1.get(
"/shopping/{list_id}",
response_model=PurchasedShoppingList,
operation_id="getShoppingList",
tags=["shopping"],
summary="Get a purchased shopping list by id",
responses={
404: {
"model": ProblemDetails,
"description": "Shopping list not found",
"content": {"application/problem+json": {}},
}
},
)
2025-10-18 03:26:42 +00:00
async def get_shopping_list(
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
list_id: int, conn: aiosqlite.Connection = Depends(get_db), request: Request = None
2025-10-18 03:26:42 +00:00
) -> PurchasedShoppingList | JSONResponse:
shopping_list = await shopping.load_shopping_list(conn, list_id)
if not shopping_list:
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
return error_response(request, 404, "Shopping list not found")
2025-10-18 03:26:42 +00:00
meals_lookup, recipes_lookup, ingredients_lookup = await shopping.to_lookups(
conn, shopping_list.items
)
return PurchasedShoppingList(
list=shopping_list,
meals_lookup=meals_lookup,
recipes_lookup=recipes_lookup,
ingredients_lookup=ingredients_lookup,
)
2024-05-19 03:43:06 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
@api_v1.post(
"/shopping/",
operation_id="purchaseIngredients",
tags=["shopping"],
summary="Purchase ingredients for a shopping list",
)
2025-10-18 03:26:42 +00:00
async def purchase_ingredients(
shopping_list: shopping.ShoppingList,
conn: aiosqlite.Connection = Depends(get_db),
person: persons.Person = Depends(cookie_person),
) -> PurchasedShoppingList:
shopping_list = shopping.ShoppingList(
purchased_by=person, items=shopping_list.items, store_name=shopping_list.store_name
)
await shopping.purchase(conn, shopping_list)
2024-05-19 03:43:06 +00:00
await conn.commit()
result = PurchasedShoppingList(list=shopping_list)
2025-10-18 03:26:42 +00:00
await shopping.to_lookups(
conn,
shopping_list.items,
result.meals_lookup,
result.recipes_lookup,
result.ingredients_lookup,
)
return result
2025-10-18 03:26:42 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
@api_v1.get(
"/shopping/current/me/ingredients",
operation_id="getMyShoppingList",
tags=["shopping"],
summary="Get my outstanding ingredient requests",
)
2025-10-18 03:26:42 +00:00
async def get_my_shopping_list(
conn: aiosqlite.Connection = Depends(get_db), person: persons.Person = Depends(cookie_person)
) -> List[ingredients.Ingredient]:
return await shopping.get_persons_requests(conn, person.id)
2024-05-18 07:05:01 +00:00
2025-10-18 03:26:42 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
@api_v1.post(
"/shopping/current/me/ingredients",
operation_id="syncMyShoppingList",
tags=["shopping"],
summary="Sync my outstanding ingredient requests",
)
2025-10-18 03:26:42 +00:00
async def sync_my_shopping_list(
requests: List[ingredients.Ingredient],
conn: aiosqlite.Connection = Depends(get_db),
person: persons.Person = Depends(cookie_person),
) -> List[ingredients.Ingredient]:
def isMatching(a: ingredients.Ingredient, b: ingredients.Ingredient) -> bool:
return a.id == b.id or a.line == b.line
my_shopping_list = await shopping.get_persons_requests(conn, person.id)
to_remove = [r for r in my_shopping_list if not any(isMatching(r, req) for req in requests)]
to_add = [req for req in requests if not any(isMatching(req, r) for r in my_shopping_list)]
for r in to_remove:
await shopping.remove_request(conn, person, ingredient=r)
2025-10-18 03:26:42 +00:00
for r in to_add:
if r.id < 0:
await ingredients.insert_ingredient(conn, r)
await shopping.request(conn, person, ingredient=r)
2024-05-18 07:05:01 +00:00
await conn.commit()
return await get_my_shopping_list(conn, person)
2024-05-18 07:05:01 +00:00
2025-10-18 03:26:42 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
class MealIdWrapper(ApiModel):
2024-05-18 07:05:01 +00:00
meal_id: int
2025-10-18 03:26:42 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
@api_v1.post(
"/shopping/current/meals/me",
response_model=None,
operation_id="requestMeal",
tags=["shopping"],
summary="Request a meal for shopping",
responses={
404: {
"model": ProblemDetails,
"description": "Meal not found",
"content": {"application/problem+json": {}},
}
},
)
2025-10-18 03:26:42 +00:00
async def request_meal(
r: MealIdWrapper,
conn: aiosqlite.Connection = Depends(get_db),
person: persons.Person = Depends(cookie_person),
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
request: Request = None,
2025-10-18 03:26:42 +00:00
) -> shopping.ShoppingListItem | JSONResponse:
2024-05-18 07:05:01 +00:00
meal = await meals.find_meal_by_id(conn, r.meal_id)
if not meal:
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
return error_response(request, 404, "Meal not found")
response = await shopping.request(conn, person, meal=meal)
2024-05-18 07:05:01 +00:00
await conn.commit()
return response
2025-10-18 03:26:42 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
@api_v1.delete(
"/shopping/current/meals/{meal_id}",
response_model=None,
operation_id="unrequestMeal",
tags=["shopping"],
summary="Remove a meal request",
responses={
404: {
"model": ProblemDetails,
"description": "Meal not found",
"content": {"application/problem+json": {}},
}
},
)
2025-10-18 03:26:42 +00:00
async def unrequest_meal(
meal_id: int,
conn: aiosqlite.Connection = Depends(get_db),
person: persons.Person = Depends(cookie_person),
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
request: Request = None,
2025-10-18 03:26:42 +00:00
) -> dict | JSONResponse:
2024-05-18 07:05:01 +00:00
meal = await meals.find_meal_by_id(conn, meal_id)
if not meal:
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
return error_response(request, 404, "Meal not found")
2024-05-18 07:05:01 +00:00
await shopping.remove_request(conn, person, meal=meal)
2024-05-18 07:05:01 +00:00
await conn.commit()
return {}
2025-10-18 06:05:48 +00:00
from api import shopping as shopping_router # type: ignore
app.include_router(shopping_router.router, prefix="/api/v1", tags=["v1"]) # extracted
2025-10-18 03:26:42 +00:00
2025-10-18 06:00:01 +00:00
from api import persons as persons_router # type: ignore
2024-04-25 02:03:30 +00:00
2025-10-18 03:26:42 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
class LoginBody(ApiModel):
2024-04-25 02:03:30 +00:00
username: str
2025-10-18 03:26:42 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
@api_v1.post(
"/auth/login",
response_model=None,
operation_id="login",
tags=["auth"],
summary="Login and set user_id cookie",
responses={
404: {
"model": ProblemDetails,
"description": "Person not found",
"content": {"application/problem+json": {}},
}
},
)
2025-10-18 03:26:42 +00:00
async def login(
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
data: LoginBody, conn: aiosqlite.Connection = Depends(get_db), request: Request = None
2025-10-18 03:26:42 +00:00
) -> persons.Person | JSONResponse:
2024-04-25 02:03:30 +00:00
person = await persons.get_by_name(conn, data.username)
if not person:
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
return error_response(request, 404, "Person not found")
2025-10-18 03:26:42 +00:00
2024-04-25 02:03:30 +00:00
response = JSONResponse(content=jsonable_encoder(person))
2025-10-18 03:26:42 +00:00
response.set_cookie(key="user_id", value=str(person.id))
2024-04-28 02:15:19 +00:00
return response
2025-10-18 03:26:42 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
@api_v1.post(
"/auth/refresh",
operation_id="refresh",
tags=["auth"],
summary="Refresh current user from cookie",
)
2024-04-28 02:15:19 +00:00
async def current_user(user: persons.Person = Depends(cookie_person)) -> persons.Person:
return user
2025-10-18 06:05:48 +00:00
from api import auth as auth_router # type: ignore
app.include_router(auth_router.router, prefix="/api/v1", tags=["v1"]) # extracted
2025-10-18 03:26:42 +00:00
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
# RFC7807 Problem Details handlers
from starlette.exceptions import HTTPException as StarletteHTTPException
from pydantic import ValidationError
from fastapi.exceptions import RequestValidationError
from fastapi.responses import JSONResponse
@app.exception_handler(StarletteHTTPException)
async def http_exc_handler(request: Request, exc: StarletteHTTPException):
body = ProblemDetails(
title=str(exc.detail) if exc.detail else "HTTP Error",
status=exc.status_code,
type=f"https://httpstatuses.com/{exc.status_code}",
instance=str(request.url),
)
return JSONResponse(
content=body.model_dump(by_alias=True),
status_code=exc.status_code,
media_type="application/problem+json",
)
@app.exception_handler(ValidationError)
async def validation_exc_handler(request: Request, exc: ValidationError):
errors: Dict[str, Any] = {}
for e in exc.errors():
loc = ".".join([str(p) for p in e.get("loc", [])])
errors.setdefault(loc, []).append(e.get("msg"))
body = ProblemDetails(
title="Validation Error",
status=422,
type="https://datatracker.ietf.org/doc/html/rfc7807",
instance=str(request.url),
errors=errors,
)
return JSONResponse(
content=body.model_dump(by_alias=True), status_code=422, media_type="application/problem+json"
)
@app.exception_handler(RequestValidationError)
async def request_validation_exc_handler(request: Request, exc: RequestValidationError):
errors: Dict[str, Any] = {}
for e in exc.errors():
loc = ".".join([str(p) for p in e.get("loc", [])])
errors.setdefault(loc, []).append(e.get("msg"))
body = ProblemDetails(
title="Validation Error",
status=422,
type="https://datatracker.ietf.org/doc/html/rfc7807",
instance=str(request.url),
errors=errors,
)
return JSONResponse(
content=body.model_dump(by_alias=True), status_code=422, media_type="application/problem+json"
)
# Mount versioned API router
app.include_router(api_v1, prefix="/api/v1", tags=["v1"])
2025-10-18 05:54:35 +00:00
app.include_router(recipes_router.router, prefix="/api/v1", tags=["v1"]) # extracted
2025-10-18 06:00:01 +00:00
app.include_router(persons_router.router, prefix="/api/v1", tags=["v1"]) # extracted
2025-10-18 05:54:35 +00:00
@app.get("/healthz")
async def healthz():
return {"status": "ok"}
Squashed commit of the following: commit 4189d9f824f681b480f797b109e963762eb22e9c Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:41:57 2025 +1100 Openapi complete commit bebf8c30cba0b85a889198fe44879614065a0c34 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:35:39 2025 +1100 Removed unversioned api commit dd9cc2eae75d66fceebe14c918c3ed8498376ee6 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:07:03 2025 +1100 Spec updates commit b993c4530688f79ea983278283f984e9d8e83860 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:01:50 2025 +1100 docs(spec): update doof-back-spec with v1 RFC7807 422, reusable Problem* responses, and shopping/current aliasing; tests passing; openapi.json refreshed commit 30bac7e57367b14ce924667a7955845de949d779 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 16:00:13 2025 +1100 openapi polish commit eb7f7f224f7085fa5b3fadc7716db0ebb7f47eb0 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:54:52 2025 +1100 OpenAPI reusable responses: Added components.responses for `Problem400`, `Problem404`, and `Problem422`; v1 routes reference these consistently. - Units enum: Exposed advisory enum in schema for `Ingredient.unit` using existing units list (no runtime enforcement). commit 037037e17d684a89b264f2406377970a0de7ec99 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:43:01 2025 +1100 Add `total` counts to v1 page responses for recipes/persons; push persons name filter into SQL for v1 when `q` is provided. commit 07e7735076aae8cbd04bb10f9aa324c1a3d80ae4 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:40:17 2025 +1100 Add parameter descriptions for `cursor`, `limit`, and `q` on v1 list endpoints; include example `Page` envelopes in 200 responses. commit e5bf9396b0fe870501d1b4712cba2555dd2ef9b1 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:36:27 2025 +1100 DB pagination commit 782315cd2a0c18cc50e4deaf28e7ec6e4b58c6e2 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:29:38 2025 +1100 camelcase tests commit b207c33e2844c00fc9e531fb9cf8c07a3f5cd543 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:24:57 2025 +1100 OpenAPI enrichment, Error responses commit dc84681ab743008e5cd8bec7f3ccb0d05b557518 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:16:39 2025 +1100 v1 tests: Added basic tests to assert `Page` envelopes and RFC7807 responses for v1 endpoints without affecting legacy tests. commit 1524b7a98ffe04af11c2731c8125ac9348751cff Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:14:51 2025 +1100 Pagination commit 92e91d7acf15c09b14bc76f7b16a7a47e65129ec Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:03:50 2025 +1100 Use middleware for naming case changes commit c68f964f9b8e3d8f8ef020661e747e0990459c81 Author: jableader <jacobdunk@gmail.com> Date: Sat Oct 18 15:00:09 2025 +1100 Openapi gen
2025-10-18 05:44:36 +00:00
2025-10-18 03:26:42 +00:00
if os.environ.get("DOOF_PROD", False):
from fastapi.staticfiles import StaticFiles
2025-10-18 03:26:42 +00:00
app.mount("/", StaticFiles(directory="./front-dist", html=True), name="front-dist")
else:
# Proxy the request to the frontend development server
2025-10-18 03:26:42 +00:00
import httpx
from starlette.background import BackgroundTask
from starlette.requests import Request
from starlette.responses import StreamingResponse
client = httpx.AsyncClient(base_url="http://localhost:8080/")
async def _reverse_proxy(request: Request):
2025-10-18 03:26:42 +00:00
url = httpx.URL(path=request.url.path, query=request.url.query.encode("utf-8"))
rp_req = client.build_request(
request.method, url, headers=request.headers.raw, content=request.stream()
)
rp_resp = await client.send(rp_req, stream=True)
return StreamingResponse(
rp_resp.aiter_raw(),
status_code=rp_resp.status_code,
headers=rp_resp.headers,
background=BackgroundTask(rp_resp.aclose),
)
2025-10-18 03:26:42 +00:00
app.add_route("/{path:path}", _reverse_proxy, ["GET", "POST"])