Add near-miss diagnostics and request count/unmatched endpoints to the admin API (#1521)

* Add near-miss diagnostics and request count/unmatched admin endpoints (#171)

Add IWireMockServer.FindUnmatchedLogEntries, FindNearMisses and
FindNearMissesForUnmatchedRequests, which rank the mappings that
partially match a request by score.

Expose them through the admin API (POST requests/count,
GET requests/unmatched, GET requests/unmatched/near-misses and
GET requests/{guid}/near-misses), the RestClient and the OpenAPI document.

* Make scenario delay tests independent of server warm-up time

The two *_StateTransitions_BeforeDelayCompletes tests waited a fixed
100 ms for the scenario state to change, which fails on a cold server.
Poll server.Scenarios until the expected state is reached instead.

---------

Co-authored-by: Mattias <13809209+Quattordici@users.noreply.github.com>
This commit is contained in:
Mattias SundströmandMattias authored and GitHub committed 2026-10-23 17:48:54 +02:00
1 parent c94824bd64
commit dc14136492
18 files changed
+1104 -62

No files matched your search

@@ -250,6 +250,39 @@ public interface IWireMockAdminApi
[Get("requests/find")]
Task<IList<LogEntryModel>> FindRequestsByMappingGuidAsync([Query] Guid mappingGuid, CancellationToken cancellationToken = default);
/// <summary>
/// Count the requests which match the criteria (<see cref="RequestModel"/>).
/// </summary>
/// <param name="model">The RequestModel</param>
/// <param name="cancellationToken">The optional cancellationToken.</param>
[Post("requests/count")]
[Header("Content-Type", "application/json")]
Task<RequestCountModel> CountRequestsAsync([Body] RequestModel model, CancellationToken cancellationToken = default);
/// <summary>
/// Get the requests which did not fully match any mapping.
/// </summary>
/// <param name="cancellationToken">The optional cancellationToken.</param>
[Get("requests/unmatched")]
Task<IList<LogEntryModel>> GetUnmatchedRequestsAsync(CancellationToken cancellationToken = default);
/// <summary>
/// Get the near misses (the mappings which partially match) for all requests which did not fully match any mapping.
/// </summary>
/// <param name="maxResults">The maximum number of near misses per request. Default is 3.</param>
/// <param name="cancellationToken">The optional cancellationToken.</param>
[Get("requests/unmatched/near-misses")]
Task<IList<NearMissModel>> GetNearMissesForUnmatchedRequestsAsync([Query] int? maxResults = null, CancellationToken cancellationToken = default);
/// <summary>
/// Get the near misses (the mappings which partially match) for a request.
/// </summary>
/// <param name="guid">The Guid of the request</param>
/// <param name="maxResults">The maximum number of near misses. Default is 3.</param>
/// <param name="cancellationToken">The optional cancellationToken.</param>
[Get("requests/{guid}/near-misses")]
Task<IList<NearMissModel>> GetNearMissesForRequestAsync([Path] Guid guid, [Query] int? maxResults = null, CancellationToken cancellationToken = default);
/// <summary>
/// Get all scenarios
/// </summary>