Remove nulls from public api
This commit is contained in:
parent
7b6f4e2a3b
commit
5a85250574
6 changed files with 35 additions and 51 deletions
|
|
@ -103,6 +103,19 @@ def extend_with_problem_and_cookie_auth(app: FastAPI) -> None:
|
|||
if not any(isinstance(s, dict) and "cookieAuth" in s for s in security):
|
||||
security.append({"cookieAuth": []})
|
||||
|
||||
# Ensure the cookie parameter is documented as required integer (non-null)
|
||||
params = op.get("parameters")
|
||||
if isinstance(params, list):
|
||||
for p in params:
|
||||
if not isinstance(p, dict):
|
||||
continue
|
||||
if p.get("in") == "cookie" and p.get("name") == "user_id":
|
||||
p["required"] = True
|
||||
schema = p.setdefault("schema", {})
|
||||
if isinstance(schema, dict):
|
||||
schema.clear()
|
||||
schema.update({"type": "integer", "title": "User Id"})
|
||||
|
||||
# Keep endpoint-specific schemas driven by route declarations only (no forced overrides)
|
||||
|
||||
return spec
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@ async def load_full_recipe(conn: aiosqlite.Connection, id: int) -> Optional[reci
|
|||
async for ingredient in ingredients.find_ingredients_by_recipe_id(conn, id):
|
||||
r.ingredients.append(ingredient)
|
||||
|
||||
if r.created_by_id is not None:
|
||||
r.created_by = await persons.get_by_id(conn, r.created_by_id)
|
||||
|
||||
return r
|
||||
|
|
|
|||
|
|
@ -53,4 +53,4 @@ class Page(ApiModel, Generic[T]):
|
|||
items: List[T]
|
||||
next_cursor: Optional[str] = Field(default=None, alias="nextCursor")
|
||||
prev_cursor: Optional[str] = Field(default=None, alias="prevCursor")
|
||||
total: Optional[int] = Field(default=None, description="Optional total count")
|
||||
total: int = Field(default=0, description="Total count")
|
||||
|
|
|
|||
53
openapi.json
53
openapi.json
|
|
@ -1866,16 +1866,10 @@
|
|||
"title": "Prevcursor"
|
||||
},
|
||||
"total": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"type": "integer",
|
||||
"title": "Total",
|
||||
"description": "Optional total count"
|
||||
"description": "Total count",
|
||||
"default": 0
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
|
|
@ -1916,16 +1910,10 @@
|
|||
"title": "Prevcursor"
|
||||
},
|
||||
"total": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"type": "integer",
|
||||
"title": "Total",
|
||||
"description": "Optional total count"
|
||||
"description": "Total count",
|
||||
"default": 0
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
|
|
@ -2046,17 +2034,6 @@
|
|||
"imgLarge": {
|
||||
"type": "string",
|
||||
"title": "Imglarge"
|
||||
},
|
||||
"rawData": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"title": "Rawdata"
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
|
|
@ -2175,14 +2152,7 @@
|
|||
"title": "Datecreated"
|
||||
},
|
||||
"createdById": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"type": "integer",
|
||||
"title": "Createdbyid"
|
||||
},
|
||||
"createdBy": {
|
||||
|
|
@ -2288,14 +2258,7 @@
|
|||
"title": "Datecreated"
|
||||
},
|
||||
"createdById": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"type": "integer",
|
||||
"title": "Createdbyid"
|
||||
},
|
||||
"createdBy": {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||
from typing import ClassVar, List, Optional
|
||||
|
||||
from common import ApiModel
|
||||
from pydantic import PrivateAttr
|
||||
|
||||
|
||||
class Product(ApiModel):
|
||||
|
|
@ -28,5 +29,13 @@ class Product(ApiModel):
|
|||
unit: str
|
||||
img_small: str
|
||||
img_large: str
|
||||
# Non-persisted field used in tests and insert helper
|
||||
raw_data: Optional[dict] = None
|
||||
# Non-persisted field used in tests and insert helper (not part of public schema)
|
||||
_raw_data: Optional[dict] = PrivateAttr(default=None)
|
||||
|
||||
@property
|
||||
def raw_data(self) -> Optional[dict]:
|
||||
return self._raw_data
|
||||
|
||||
@raw_data.setter
|
||||
def raw_data(self, value: Optional[dict]) -> None:
|
||||
self._raw_data = value
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class Recipe(ApiModel):
|
|||
date_created: datetime.datetime = Field(
|
||||
default_factory=lambda: datetime.datetime.now().astimezone()
|
||||
)
|
||||
created_by_id: Optional[int]
|
||||
created_by_id: int
|
||||
created_by: Optional[Person] = None
|
||||
|
||||
date_hidden: Optional[datetime.datetime] = None
|
||||
|
|
|
|||
Loading…
Reference in a new issue