Class MockConfiguration

Namespace
Kuestenlogik.Bowire.Mocking
Assembly
Kuestenlogik.Bowire.dll

Operator-authored refinement layer for a schema-generated mock (#558). A schema mock synthesises plausible-but-generic responses from the declared types; this configuration is the persisted sidecar that lets an operator refine them without re-discovering: per-field response overrides (applied here, in this slice), per-method conditional-response rules, and an auth-requirement block.

public sealed class MockConfiguration
Inheritance
MockConfiguration
Inherited Members

Remarks

This is the shared, cross-cutting contract every mock-refinement slice serializes into. Only FieldOverrides is evaluated in the foundation slice (via MockConfigApplier); ConditionalRules and Auth are model-only here and are consumed by the sibling editor / auth slices (#561 / #562).

The store (MockConfigStore) persists this as a workspace artifact at workspaces/<wsId>/mocks/<mockId>.json; the bowire mock --mock-config <file> flag loads one at startup.

Constructors

MockConfiguration()

public MockConfiguration()

Fields

CurrentFormatVersion

The envelope version this build writes. Bump on a breaking shape change.

public const int CurrentFormatVersion = 1

Field Value

int

Properties

Auth

Auth-requirement block. Model-only here; enforced by #562.

[JsonPropertyName("auth")]
public MockAuthRequirement? Auth { get; set; }

Property Value

MockAuthRequirement

ConditionalRules

Per-method conditional-response rules. Model-only here; evaluated by #561.

[JsonPropertyName("conditionalRules")]
public IList<MockConditionalRule> ConditionalRules { get; init; }

Property Value

IList<MockConditionalRule>

ConfigFormatVersion

On-disk envelope version. Read version-tolerantly: an absent value defaults to CurrentFormatVersion; a newer value loads best-effort because unknown fields are ignored (see Parse(string?)).

[JsonPropertyName("configFormatVersion")]
public int ConfigFormatVersion { get; set; }

Property Value

int

FieldOverrides

Per-field response overrides — the only arm evaluated in this slice. Never null after a successful Parse(string?) (an explicit "fieldOverrides": null token is rejected, not silently kept).

[JsonPropertyName("fieldOverrides")]
public IList<MockFieldOverride> FieldOverrides { get; init; }

Property Value

IList<MockFieldOverride>

Source

Which schema source this configuration refines. Diagnostic; not required to apply.

[JsonPropertyName("source")]
public MockConfigSource? Source { get; set; }

Property Value

MockConfigSource

Methods

Parse(string?)

Parse a mock-configuration document. Version-tolerant by design:

  • an empty / whitespace document yields a default (empty) configuration;
  • an absent configFormatVersion stays at CurrentFormatVersion (backward tolerance); a non-positive one is normalised to it;
  • a newer version loads best-effort — System.Text.Json ignores unknown properties, so a forward-compatible reader keeps working (forward tolerance).

Throws JsonException when the payload is not valid JSON of the expected object shape, or when a collection arm is explicitly null ("fieldOverrides": null) — use [] or omit it; this keeps every consumer's collection non-null.

public static MockConfiguration Parse(string? json)

Parameters

json string

Returns

MockConfiguration

ToJson()

Serialize to the canonical on-disk / wire JSON shape.

public string ToJson()

Returns

string