mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-25 02:21:00 +01:00
Added support of custom matchers in static mappings (#713)
* Added support of custom matchers in static mappings * Fixed code style issues * Fixed naming and code style * added empty line * Ignore serialization of CustomMatcherMappings property in WireMockServerSettings * Added integration tests for CustomMatcherMappings
This commit is contained in:
@@ -105,6 +105,11 @@ namespace WireMock.Serialization
|
||||
return new SimMetricsMatcher(matchBehaviour, stringPatterns, type, throwExceptionWhenMatcherFails);
|
||||
|
||||
default:
|
||||
if (_settings.CustomMatcherMappings != null && _settings.CustomMatcherMappings.ContainsKey(matcherName))
|
||||
{
|
||||
return _settings.CustomMatcherMappings[matcherName](matcher);
|
||||
}
|
||||
|
||||
throw new NotSupportedException($"Matcher '{matcherName}' is not supported.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using HandlebarsDotNet;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
using WireMock.Admin.Mappings;
|
||||
using WireMock.Handlers;
|
||||
using WireMock.Logging;
|
||||
using WireMock.Matchers;
|
||||
@@ -229,5 +232,11 @@ namespace WireMock.Settings
|
||||
/// </summary>
|
||||
[PublicAPI]
|
||||
bool? SaveUnmatchedRequests { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Custom matcher mappings for static mappings
|
||||
/// </summary>
|
||||
[PublicAPI, JsonIgnore]
|
||||
IDictionary<string, Func<MatcherModel, IMatcher>> CustomMatcherMappings { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using HandlebarsDotNet;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
using WireMock.Admin.Mappings;
|
||||
using WireMock.Handlers;
|
||||
using WireMock.Logging;
|
||||
using WireMock.Matchers;
|
||||
#if USE_ASPNETCORE
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
#endif
|
||||
@@ -158,5 +161,9 @@ namespace WireMock.Settings
|
||||
/// <inheritdoc cref="IWireMockServerSettings.SaveUnmatchedRequests"/>
|
||||
[PublicAPI]
|
||||
public bool? SaveUnmatchedRequests { get; set; }
|
||||
|
||||
/// <inheritdoc cref="IWireMockServerSettings.CustomMatcherMappings"/>
|
||||
[PublicAPI, JsonIgnore]
|
||||
public IDictionary<string, Func<MatcherModel, IMatcher>> CustomMatcherMappings { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user