Skip to content

Commit 638fa84

Browse files
docs: clarify that if let Ok guard on from_value is infallible for serde_json::Value
Add inline comment explaining that deserializing into serde_json::Value always succeeds, so the Ok branch always fires. The guard future-proofs against typed additionalProperties schemas where the conversion could fail. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 336a84c commit 638fa84

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

.generator/src/generator/templates/model_simple.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ impl<'de> Deserialize<'de> for {{ name }} {
119119

120120
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
121121
{%- if additionalProperties != false and model.get("x-keep-typed-in-additional-properties") %}
122+
// from_value::<serde_json::Value> is infallible; the Ok guard future-proofs typed AP schemas.
122123
if let Ok(ap_value) = serde_json::from_value(v.clone()) {
123124
additional_properties.insert(k.clone(), ap_value);
124125
}

0 commit comments

Comments
 (0)