Problem
For an object schema with declared properties and typed additionalProperties, Typify generates a struct containing the declared fields plus a public flattened map. Callers can insert a declared property name into that map. For example, a map entry named id can conflict with the struct's declared id field and may produce duplicate or ambiguous serialized keys.
Deserialization routes declared names to their declared fields, so unrestricted construction of the flattened map does not preserve the same invariant in both directions.
Possible direction
Represent additional-property keys with a generated newtype or map wrapper that rejects names reserved by declared properties. The exact representation should preserve normal map ergonomics while preventing invalid construction and serialization.
Coverage
Add tests for:
- constructing the additional-properties map with a declared key;
- serialization without duplicate/conflicting keys;
- deserialization of declared and additional keys;
- serialize/deserialize round trips.
This was identified while reviewing #1039 and is intentionally kept separate from that PR's narrow invalid-Rust fix.
Problem
For an object schema with declared properties and typed
additionalProperties, Typify generates a struct containing the declared fields plus a public flattened map. Callers can insert a declared property name into that map. For example, a map entry namedidcan conflict with the struct's declaredidfield and may produce duplicate or ambiguous serialized keys.Deserialization routes declared names to their declared fields, so unrestricted construction of the flattened map does not preserve the same invariant in both directions.
Possible direction
Represent additional-property keys with a generated newtype or map wrapper that rejects names reserved by declared properties. The exact representation should preserve normal map ergonomics while preventing invalid construction and serialization.
Coverage
Add tests for:
This was identified while reviewing #1039 and is intentionally kept separate from that PR's narrow invalid-Rust fix.