Skip to main content

Schema generation

[ValiantSettings] is the generator discovery boundary. It produces a deterministic ValiantSettingsSchema for the marked type.

[ValiantSettings("Search")]
public sealed record SearchSettings
{
public required Uri Endpoint { get; init; }
public SearchRetrySettings Retry { get; init; } = new();
public string[] Indexes { get; init; } = [];
}

public sealed record SearchRetrySettings
{
public int Attempts { get; init; } = 3;
public TimeSpan Delay { get; init; } = TimeSpan.FromSeconds(1);
}

The model schema contains its CLR type, display name, section path, and ordered property schemas. Each property records:

  • CLR name and configuration key;
  • type display name and normalized kind;
  • required and nullable flags;
  • secret flag and known default value;
  • nested object properties or collection item schema.

Property kinds

KindRepresents
StringText and string-like configuration values
BooleanBoolean values
IntegerIntegral numeric values
NumberFloating-point and decimal values
EnumEnum values
ObjectNested settings object
ArrayArray or collection with an item schema
UnknownA type without a more specific schema classification

Schema-only or configured

Schema generation always occurs. Binding is opt-in:

[ValiantSettings("Features")]
public sealed record FeatureCatalog; // schema only

[ValiantSettings("Features", configure: true)]
public sealed record BoundFeatureCatalog; // schema + Options binding

This lets libraries publish metadata without changing the host's service graph.

Secret metadata

[ValiantSecret]
public string? ClientSecret { get; init; }

ValiantSecret tells schema consumers that runtime values must be hidden. The ASP.NET Core UI also masks common sensitive names defensively, but explicit attributes are the durable contract for custom tools.

Deterministic output

Generated schemas are stable enough for tooling to sort, diff, cache, and render. No runtime type scan is required to discover marked settings models.