-
Notifications
You must be signed in to change notification settings - Fork 36
feat(rust): add serde flatten to Declaration in generated output #206
Description
Feature Request
Add #[serde(flatten)] support to Rust codegen for base types
Use Case
When deserializing Concerto JSON AST into Rust structs, Declaration silently drops subtype-specific fields like properties, isAbstract, and superType.
Possible Solution
In rustvisitor.js, detect when a class is Declaration and add a #[serde(flatten)] pub extra: HashMap<String, serde_json::Value> catch-all field. Also add the necessary HashMap and serde_json imports.
Context
Currently this is hand-edited in concerto-rust with a TODO comment (see accordproject/concerto-rust#7). Attempted in #205 but the change touched snapshots across multiple generated files. Moving it to the codegen ensures it survives regeneration.
Detailed Description
Scoped to Declaration only -- adding flatten to all base types causes stack overflow from nested serde deserialization on types like MapKeyType/MapValueType.