Skip to content

Commit fc7de8b

Browse files
dougborgclaude
andcommitted
docs: address second Copilot review on #729
Two findings: 1. The Factory date-time gap rationale was in YAML comments, which OpenAPI / JSON Schema consumers discard at parse time — generated docstrings and downstream tooling never saw it. Moved the wire-vs- spec note into the ``description`` fields for ``default_so_delivery_time`` / ``default_po_lead_time`` so it propagates into the regenerated client. 2. ``_convert_nested_value``'s docstring still said unregistered attrs objects are "returned as-is", but the new behavior falls back to ``value.to_dict()`` when available. Rewrote the ``Note:`` block so callers know what conversion guarantees they actually get. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 043acd9 commit fc7de8b

3 files changed

Lines changed: 34 additions & 13 deletions

File tree

docs/katana-openapi.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10190,20 +10190,24 @@ components:
1019010190
base_currency_code:
1019110191
type: string
1019210192
description: Base currency code
10193-
# Schema gap: Katana's upstream example shows these as ISO-8601 datetimes,
10194-
# but the live wire delivers either ``null`` or an opaque short string
10195-
# (e.g. ``"14"`` for days-lead-time). ``format: date-time`` is omitted
10196-
# because the wire doesn't honor it.
1019710193
default_so_delivery_time:
1019810194
type:
1019910195
- string
1020010196
- "null"
10201-
description: Default sales order delivery time
10197+
description: |-
10198+
Default sales order delivery time. Note: Katana's upstream
10199+
example shows an ISO-8601 datetime, but the live wire delivers
10200+
either ``null`` or an opaque short string (e.g. ``"14"`` for
10201+
days). ``format: date-time`` is intentionally omitted.
1020210202
default_po_lead_time:
1020310203
type:
1020410204
- string
1020510205
- "null"
10206-
description: Default purchase order lead time
10206+
description: |-
10207+
Default purchase order lead time. Same shape as
10208+
``default_so_delivery_time`` — wire delivers ``null`` or an
10209+
opaque short string, not a datetime. ``format: date-time``
10210+
intentionally omitted.
1020710211
default_manufacturing_location_id:
1020810212
type: integer
1020910213
description: Default manufacturing location ID

katana_public_api_client/models_pydantic/_base.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,14 @@ def _convert_nested_value(value: Any, registry: Any) -> Any:
253253
The converted value suitable for a Pydantic model.
254254
255255
Note:
256-
If an attrs object is not registered in the registry, a warning is logged
257-
and the original attrs object is returned as-is. This may cause issues
258-
with Pydantic validation.
256+
For attrs objects without a registered pydantic class, falls back
257+
to ``value.to_dict()`` when the attrs side exposes that method —
258+
covers the OpenAPI ``type: object`` (no $ref / no inline properties)
259+
case where the pydantic generator emits ``dict[str, Any]`` while
260+
the attrs generator still synthesizes a concrete class. When the
261+
attrs object also has no ``to_dict``, the value is returned as-is
262+
with a warning; pydantic validation will surface the mismatch
263+
downstream.
259264
"""
260265
import logging
261266

katana_public_api_client/models_pydantic/_generated/common.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -852,10 +852,16 @@ class Factory(KatanaPydanticBase):
852852
display_name: Annotated[str, Field(description="Display name of the company")]
853853
base_currency_code: Annotated[str, Field(description="Base currency code")]
854854
default_so_delivery_time: Annotated[
855-
str | None, Field(description="Default sales order delivery time")
855+
str | None,
856+
Field(
857+
description='Default sales order delivery time. Note: Katana\'s upstream\nexample shows an ISO-8601 datetime, but the live wire delivers\neither ``null`` or an opaque short string (e.g. ``"14"`` for\ndays). ``format: date-time`` is intentionally omitted.'
858+
),
856859
] = None
857860
default_po_lead_time: Annotated[
858-
str | None, Field(description="Default purchase order lead time")
861+
str | None,
862+
Field(
863+
description="Default purchase order lead time. Same shape as\n``default_so_delivery_time`` — wire delivers ``null`` or an\nopaque short string, not a datetime. ``format: date-time``\nintentionally omitted."
864+
),
859865
] = None
860866
default_manufacturing_location_id: Annotated[
861867
int | None, Field(description="Default manufacturing location ID")
@@ -1308,10 +1314,16 @@ class CachedFactory(KatanaPydanticBase, table=True):
13081314
]
13091315
base_currency_code: Annotated[Mapped[str], Field(description="Base currency code")]
13101316
default_so_delivery_time: Annotated[
1311-
Mapped[str | None], Field(description="Default sales order delivery time")
1317+
Mapped[str | None],
1318+
Field(
1319+
description='Default sales order delivery time. Note: Katana\'s upstream\nexample shows an ISO-8601 datetime, but the live wire delivers\neither ``null`` or an opaque short string (e.g. ``"14"`` for\ndays). ``format: date-time`` is intentionally omitted.'
1320+
),
13121321
] = None
13131322
default_po_lead_time: Annotated[
1314-
Mapped[str | None], Field(description="Default purchase order lead time")
1323+
Mapped[str | None],
1324+
Field(
1325+
description="Default purchase order lead time. Same shape as\n``default_so_delivery_time`` — wire delivers ``null`` or an\nopaque short string, not a datetime. ``format: date-time``\nintentionally omitted."
1326+
),
13151327
] = None
13161328
default_manufacturing_location_id: Annotated[
13171329
Mapped[int | None], Field(description="Default manufacturing location ID")

0 commit comments

Comments
 (0)