Repository navigation
Conversation
…iremock#1515) - Add WireMockServerSettings.ScribanRegistrationCallback (Action<object, IFileSystemHandler>?) so code-configured servers can add functions, objects or variables to Scriban and Scriban-DotLiquid templates. - Pass the settings to ScribanContextFactory, which invokes the callback with a new ScriptObject per transformer context. - Push the custom globals beneath the template model in ScribanContext so request, response, mapping and data take precedence; keep the original Template.Render call when no callback is configured. - Add the strongly typed WithScribanRegistration extension method. - Add a Scriban example to the .NET 8 console app. - Make the proxy tests use a local target server instead of www.google.com, and skip the IPv6 loopback test when the OS has no IPv6 support.
This was referenced Oct 24, 2026
Closed
This was referenced Oct 28, 2026
hangy
pushed a commit
to hangy/NLog.Targets.ApplicationInsights
that referenced
this pull request
Nov 1, 2026
Updated [WireMock.Net](https://github.com/wiremock/WireMock.Net) from 2.18.0 to 2.21.0. <details> <summary>Release notes</summary> _Sourced from [WireMock.Net's releases](https://github.com/wiremock/WireMock.Net/releases)._ ## 2.21.0 ## What's Changed * Update Scriban to 7.5.3 by @StefH in wiremock/WireMock.Net#1526 **Full Changelog**: wiremock/WireMock.Net@2.20.0...2.21.0 ## 2.20.0 ## What's Changed * Add ScribanRegistrationCallback to register custom Scriban functions by @Quattordici in wiremock/WireMock.Net#1516 * Bump MessagePack from 2.5.302 to 2.5.303 by @StefH in wiremock/WireMock.Net#1519 * Downgrade JsonPath.Net from 3.0.2 to 2.2.0 to avoid Open Source Maintenance Fee issues by @StefH in wiremock/WireMock.Net#1522 * Fix workflow permissions by @StefH in wiremock/WireMock.Net#1523 * Add near-miss diagnostics and request count/unmatched endpoints to the admin API by @Quattordici in wiremock/WireMock.Net#1521 ## New Contributors * @Quattordici made their first contribution in wiremock/WireMock.Net#1516 **Full Changelog**: wiremock/WireMock.Net@2.19.0...2.20.0 ## 2.19.0 ## What's Changed * Add example /test by @StefH in wiremock/WireMock.Net#1513 * Use IDateTimeUtils in WireMockWebSocketContext by @StefH in wiremock/WireMock.Net#1512 * Fix DateTime in Response by @StefH in wiremock/WireMock.Net#1514 **Full Changelog**: wiremock/WireMock.Net@2.18.0...2.19.0 Commits viewable in [compare view](wiremock/WireMock.Net@2.18.0...2.21.0). </details> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This was referenced Nov 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1515
Before
Handlebars templates could be extended with custom helpers through
WireMockServerSettings.HandlebarsRegistrationCallback, but Scriban and Scriban-DotLiquid templates had no way to add custom functions.After
WireMockServerSettings.ScribanRegistrationCallback(Action<object, IFileSystemHandler>?) lets code-configured servers add functions, objects or variables to a ScribanScriptObject. Those members are available in bothTransformerType.ScribanandTransformerType.ScribanDotLiquidtemplates, for responses, webhooks, proxy URL replacement and WebSockets.The first argument is a
Scriban.Runtime.ScriptObjectfromScriban.Signed. It is typed asobjectso that WireMock.Net.Shared does not depend on Scriban. The registered globals sit beneath the template model, sorequest,response,mappinganddataalways win on a name clash. Template assignments write to the model scope and never change the registered globals.How
WireMockServerSettingsgets the newScribanRegistrationCallbackproperty ([PublicAPI],[JsonIgnore]), next toHandlebarsRegistrationCallback.TransformerFactorynow passes the settings toScribanContextFactory. The factory invokes the callback with a newScriptObjecteach time it creates a transformer context, the same lifetime as the Handlebars callback.ScribanContextbuilds theTemplateContextitself when custom globals exist (LiquidTemplateContextfor DotLiquid), pushing the custom globals first and the model second. When no callback is configured, it still callsTemplate.Render(model, renamer)exactly as before, so existing users see no change.WireMockServerSettingsExtensions.WithScribanRegistration(Action<ScriptObject, IFileSystemHandler>)in WireMock.Net.Minimal gives a strongly typed alternative. It keeps any callback that is already configured and runs it first, so several libraries can register functions.greetfunction used from a Scriban mapping.Tests
ScribanContextFactoryTests: callback invoked once per context with aScriptObjectand the settings'IFileSystemHandler, and a newScriptObjectper context.ScribanContextTests(new): custom functions with and without arguments (Liquid as a filter), model precedence over custom globals, custom globals over Scriban built-ins, template assignments not mutating custom globals, and output parity with and without an empty set of custom globals for both Scriban types.ResponseWithScribanTests: the custom function in the body, a header and a JSON body, for both Scriban types.WireMockServerSettingsTests: an HTTP round trip against a running server, for both Scriban types.WireMockServerSettingsExtensionsTests(new): typed callback, chaining order and argument guards.Test reliability fixes
These tests failed in environments without outbound internet or IPv6, independent of this feature:
WireMockServerProxyTests: seven tests proxied tohttp://www.google.com. They now proxy to a localWireMockServerstarted per test, so they no longer depend on the network. Two of them (..._Should_Not_SaveMapping) andWireMockServer_Proxy_Should_proxy_responsespreviously passed even when the proxy call failed; they now exercise a real proxied response, and the latter asserts the exact proxied body.WireMockServer_Should_respond_to_ipv6_loopbackis skipped at runtime withAssert.SkipUnless(Socket.OSSupportsIPv6, ...)when the OS has no IPv6 support, instead of failing with a socket error.