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 byNseconds.{{timestamp}}— current UTC time as ISO 8601.{{random}}— randomuint32.{{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;OPis== != < > <= >=, or a bare truthy value.{{upper:X}}/{{lower:X}}— case folding.{{default:X|Y}}—Xunless empty, elseY.
{{{{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
bodystring
Returns
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
bodystringrequestRequestTemplateextraBindingsIReadOnlyDictionary<string, string>
Returns
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
bodystringextraBindingsIReadOnlyDictionary<string, string>