Skip to content

feat(rust): add serde flatten to Declaration in generated output #206

@vyuan2037

Description

@vyuan2037

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions