docs(api): say which unit the batch route reads a sample in

U1. The new `unit` description on the batch entry said `value` is read in
the unit HealthLog stores the identifier in. Sixteen mappings disagree:
`convertToDbUnit` runs on every entry, and a waist circumference arrives
in metres to be stored in centimetres, an oxygen saturation and a body fat
arrive as a fraction to be stored as a percent. A client generated against
that sentence sends 98 and stores 9800.

The description now says what happens: `value` is read in Apple's own
HKUnit for the identifier, HealthLog applies its storage scaling
afterwards, and `unit` is recorded for audit rather than validated
against. Two worked examples, because the percent-shaped ones are the pair
that bites. YAML regenerated.
This commit is contained in:
Marc-André Bombeck committed 2026-09-10 01:29:08 +02:00
1 parent 779cd3a0c8
commit e4333f8f71
2 files changed
+7 -4

No files matched your search

+6 -3
View File
@@ -21350,9 +21350,12 @@ components:
type: string
minLength: 1
maxLength: 60
description: "Apple's `HKUnit` string for `value`, captured for audit. The server does NOT convert from it: `value` is
read in the unit HealthLog stores the identifier in (`m` for walking distance, `kg` for body mass, `kcal`
for energy, `degC` for temperature). Send the sample in that unit."
description: "Apple's `HKUnit` string for `value`, captured for audit: the server records it and never validates `value`
against it. `value` is read in Apple's own `HKUnit` for the identifier — `m` for a length, `kg` for body
mass, `kcal` for energy, `degC` for temperature, a `fraction` for the percent-shaped ones (oxygen
saturation, body fat) — and HealthLog applies its storage scaling after that. A waist circumference sent as
`0.86` in `m` is stored as `86` `cm`; an oxygen saturation sent as `0.98` in `fraction` is stored as `98`
`%`. Send the sample in Apple's unit, not in HealthLog's."
startDate:
type: string
format: date-time
+1 -1
View File
@@ -58,7 +58,7 @@ const batchEntrySchema = z
.min(1)
.max(60)
.describe(
"Apple's `HKUnit` string for `value`, captured for audit. The server does NOT convert from it: `value` is read in the unit HealthLog stores the identifier in (`m` for walking distance, `kg` for body mass, `kcal` for energy, `degC` for temperature). Send the sample in that unit.",
"Apple's `HKUnit` string for `value`, captured for audit: the server records it and never validates `value` against it. `value` is read in Apple's own `HKUnit` for the identifier — `m` for a length, `kg` for body mass, `kcal` for energy, `degC` for temperature, a `fraction` for the percent-shaped ones (oxygen saturation, body fat) — and HealthLog applies its storage scaling after that. A waist circumference sent as `0.86` in `m` is stored as `86` `cm`; an oxygen saturation sent as `0.98` in `fraction` is stored as `98` `%`. Send the sample in Apple's unit, not in HealthLog's.",
),
startDate: z.iso.datetime({ offset: true }),
endDate: z.iso.datetime({ offset: true }),