Skip to main content

Module compositions

Module compositions 

Source
Expand description

Generators for oneOf / allOf / anyOf schema compositions.

  • oneOf โ†’ Rust enum. Tagged via #[serde(tag = "...")] when the schema carries a discriminator; otherwise #[serde(untagged)].
  • anyOf โ†’ Rust enum, always #[serde(untagged)] (oneOf semantics without the exclusivity guarantee is rarely useful in typed Rust).
  • allOf โ†’ Rust struct that merges its branches: $ref branches become #[serde(flatten)] fields; inline object branches inline their properties directly.

SchemaKind::Not and SchemaKind::Any remain unsupported and continue to fall back to serde_json::Value in super::types.

Inline (non-top-level) compositions are synthesized into top-level types using a deterministic name derived from the enclosing context (object name + property, operation id + role). The accumulated definitions are emitted alongside the explicit components/schemas items so all generated types live at module scope.

Functionsยง

generate_all_of
Generate a Rust struct type for an allOf composition.
generate_any_of
Generate a Rust enum type for an anyOf composition.
generate_one_of
Generate a Rust enum type for a oneOf composition.