oxidecomputer / oxidecomputer/typify
Prevent flattened additionalProperties keys from colliding with declared properties
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 898
- Forks
- 114
- Avg merge
- 4h 18m
- Merged PRs (30d)
- 14
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file or test path is named. Start by tracing the generated representation and serialization/deserialization paths for declared properties and typed additionalProperties; compare the proposed map wrapper or newtype options. Done means declared names cannot be inserted as additional keys, and the requested construction, conflict-free serialization, key routing, and round-trip tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100