checkedKey function
Reads a key that is required to be present in json but whose value
may legitimately be null (OpenAPI 3.1 type: [T, "null"] combined
with required). A plain json[key] as T? cast would otherwise
accept a missing key as a null value, silently violating required.
Throws FormatException when the key is absent.
Implementation
dynamic checkedKey(Map<String, dynamic> json, String key) {
if (!json.containsKey(key)) {
throw FormatException("Missing required key '$key'", json);
}
return json[key];
}