Class ResponseBodySubstitutor

Namespace
Kuestenlogik.Bowire.Mock.Replay
Assembly
Kuestenlogik.Bowire.Mock.dll

Substitutes dynamic placeholders inside a recorded response body at replay time, using Bowire's canonical {{name}} variable syntax (Postman / v2.2 — same delimiter as the workbench variable resolver and WireMock's Handlebars templating).

public static class ResponseBodySubstitutor
Inheritance
ResponseBodySubstitutor
Inherited Members

Remarks

Value tokens (leaf generators):

  • {{uuid}} — fresh UUID v4 per substitution.
  • {{now}} / {{nowMs}} — current Unix timestamp (s / ms).
  • {{now+N}} / {{now-N}}{{now}} shifted by N seconds.
  • {{timestamp}} — current UTC time as ISO 8601.
  • {{random}} — random uint32.
  • {{faker.*}} — fake data (name / email / int(a,b) / lorem(n) / …).
  • {{request.*}} — inbound-request values (see RequestTemplate).

Expression helpers (#430) — the argument is substituted first, so helpers can nest value tokens:

  • {{math:EXPR}} — arithmetic over + - * / % and parens, e.g. {{math:{{request.body.qty}} * 2}}.
  • {{if:A OP B ? THEN : ELSE}} — ternary; OP is == != < > <= >=, or a bare truthy value.
  • {{upper:X}} / {{lower:X}} — case folding.
  • {{default:X|Y}}X unless empty, else Y.

{{{{name}}}} escapes to a literal {{name}}. Unknown tokens are left verbatim. Loops / block templates aren't supported by this flat syntax (tracked as a follow-up).

Deprecated: the legacy ${name} dollar syntax is still resolved (leaf tokens only, no helpers) for recordings authored before the move to {{name}}, but it is deprecated and slated for removal in v3.0 — author new recordings with {{name}}.

Methods

Substitute(string)

Apply placeholder substitution to body. Built-ins (uuid/now/faker/…) → request tokens → extra bindings → literal fallback; built-ins win so a hostile extra-binding can't spoof a generator.

public static string Substitute(string body)

Parameters

body string

Returns

string

Substitute(string, RequestTemplate?, IReadOnlyDictionary<string, string>?)

Apply placeholder substitution to body. Built-ins (uuid/now/faker/…) → request tokens → extra bindings → literal fallback; built-ins win so a hostile extra-binding can't spoof a generator.

public static string Substitute(string body, RequestTemplate? request, IReadOnlyDictionary<string, string>? extraBindings)

Parameters

body string
request RequestTemplate
extraBindings IReadOnlyDictionary<string, string>

Returns

string

Substitute(string, IReadOnlyDictionary<string, string>?)

Apply placeholder substitution to body. Built-ins (uuid/now/faker/…) → request tokens → extra bindings → literal fallback; built-ins win so a hostile extra-binding can't spoof a generator.

public static string Substitute(string body, IReadOnlyDictionary<string, string>? extraBindings)

Parameters

body string
extraBindings IReadOnlyDictionary<string, string>

Returns

string