Skip to main content

Module init_template

Module init_template 

Source
Expand description

Schema-driven YAML template emitter for faucet init.

Given a schemars-emitted JSON Schema for a connector config struct, schema_to_yaml_template walks the schema’s properties and produces a comment-annotated YAML block suitable for pasting under config: in a generated pipeline file. Required fields are surfaced with placeholder values and a # REQUIRED comment; optional fields are commented out so users can opt in by uncommenting and editing.

The emitter is intentionally a string builder rather than a serde_yaml round-trip: comments and required/optional distinctions matter to the reader and would be lost by any round-trip through a generic YAML value.

Structs§

TaggedEnumField
A top-level property whose schema is a tagged enum (oneOf with a const discriminator field). Returned by discover_tagged_enum_fields so the CLI’s interactive mode can prompt the user for the variant before emitting the scaffold.

Functions§

discover_tagged_enum_fields
Walk the top-level properties of schema and return every property whose schema is a tagged enum. $refs are resolved against $defs.
schema_to_yaml_template
Render the properties of schema as a YAML block, indented by indent_spaces columns. Returns a string that always ends with \n.
schema_to_yaml_template_with_choices
Like schema_to_yaml_template, but each entry in choices overrides the inlined variant for a tagged-enum field whose property name matches the key. (e.g. choices.insert("auth", "Bearer") makes the Bearer variant the inlined default.) Unknown variant tags fall back to the first variant.