Skip to content

Commit 49e3687

Browse files
Niklas Hildebrandtclaude
authored andcommitted
fix(2.2.1): make optional Session/ChargingPeriod fields omittable
Several "X | None" fields had no default, so they were required-but-nullable — a counterparty (SMATRICS) that omits them entirely got a 422. Add `= None` defaults to ChargingPeriod.tariff_id and Session.end_date_time / authorization_reference / meter_id / total_cost so omitting them is accepted. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7b8e2ed commit 49e3687

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

ocpi/modules/cdrs/v_2_2_1/schemas.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ class ChargingPeriod(BaseModel):
5050

5151
start_date_time: DateTime
5252
dimensions: list[CdrDimension]
53-
tariff_id: CiString(36) | None # type: ignore
53+
# Optional per spec: allow it to be omitted entirely (not just null), so a CPO
54+
# that doesn't send tariff_id doesn't trigger a 422.
55+
tariff_id: CiString(36) | None = None # type: ignore
5456

5557

5658
class CdrToken(BaseModel):

ocpi/modules/sessions/v_2_2_1/schemas.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ class Session(BaseModel):
1515
party_id: CiString(3) # type: ignore
1616
id: CiString(36) # type: ignore
1717
start_date_time: DateTime
18-
end_date_time: DateTime | None
18+
end_date_time: DateTime | None = None
1919
kwh: Number
2020
cdr_token: CdrToken
2121
auth_method: AuthMethod
22-
authorization_reference: CiString(36) | None # type: ignore
22+
authorization_reference: CiString(36) | None = None # type: ignore
2323
location_id: CiString(36) # type: ignore
2424
evse_uid: CiString(36) # type: ignore
2525
connector_id: CiString(36) # type: ignore
26-
meter_id: String(255) | None # type: ignore
26+
meter_id: String(255) | None = None # type: ignore
2727
currency: String(3) # type: ignore
2828
charging_periods: list[ChargingPeriod] = []
29-
total_cost: Price | None
29+
total_cost: Price | None = None
3030
status: SessionStatus
3131
last_updated: DateTime
3232

0 commit comments

Comments
 (0)