How to match date param to a certain date range when using the Admin Api Client #523

Closed
opened 2025-12-29 08:29:27 +01:00 by adam · 3 comments
Owner

Originally created by @doddi321 on GitHub (Jun 27, 2023).

Originally assigned to: @StefH on GitHub.

I'm using Testcontainers and using the the admin client to create the mappings like so:

        await iLApi.ResetMappingsAsync();
        var mappingBuilder = iLApi.GetMappingBuilder();
        mappingBuilder.Given(m => m
            .WithRequest(req => req
                .UsingGet()
                .WithPath("/api/claimants/modified")
            )
            .WithResponse(rsp => rsp
                .WithStatusCode(StatusCodes.Status200OK)
                .WithBodyAsJson(ILModifiedClaimants)
            )
        ); 

I need to match a date query parameter to a certain date range, f.x. /api/claimants/modified?since=....

I know the LinqMatcher exists which seems fit my needs perfectly but the only thing that the .WithParams method accepts is the MatcherModel which seems to only support Regex.

Is what I am asking possible and if so how?

Originally created by @doddi321 on GitHub (Jun 27, 2023). Originally assigned to: @StefH on GitHub. I'm using Testcontainers and using the the admin client to create the mappings like so: ```C# var iLApi = apiWebFactory.ILApiMockContainer.CreateWireMockAdminClient(); await iLApi.ResetMappingsAsync(); var mappingBuilder = iLApi.GetMappingBuilder(); mappingBuilder.Given(m => m .WithRequest(req => req .UsingGet() .WithPath("/api/claimants/modified") ) .WithResponse(rsp => rsp .WithStatusCode(StatusCodes.Status200OK) .WithBodyAsJson(ILModifiedClaimants) ) ); ``` I need to match a date query parameter to a certain date range, f.x. /api/claimants/modified?since=.... I know the LinqMatcher exists which seems fit my needs perfectly but the only thing that the .WithParams method accepts is the MatcherModel which seems to only support Regex. Is what I am asking possible and if so how?
adam added the question label 2025-12-29 08:29:27 +01:00
adam closed this issue 2025-12-29 08:29:28 +01:00
Author
Owner

@StefH commented on GitHub (Jun 27, 2023):

Hello @doddi321.

Good question.

I'll take look.

@StefH commented on GitHub (Jun 27, 2023): Hello @doddi321. Good question. I'll take look.
Author
Owner

@StefH commented on GitHub (Jun 27, 2023):

@doddi321
It should work, example:

[
  {
    "Guid": "41372914-1838-4c67-916b-b9aacdd096ce",
    "UpdatedAt": "2023-01-14T15:16:17",
    "Request": {
      "Path": {
        "Matchers": [
          {
            "Name": "WildcardMatcher",
            "Pattern": "/foo",
            "IgnoreCase": false
          }
        ]
      },
      "Methods": [
        "GET"
      ],
      "Params": [
        {
          "Name": "test",
          "Matchers": [
            {
              "Name": "LinqMatcher",
              "Pattern": "it.Length < 10"
            }
          ]
        }
      ]
    },
    "Response": {
      "BodyDestination": "SameAsSource",
      "Body": "{ msg: \"Hello world!\"}"
    }
  }
]
@StefH commented on GitHub (Jun 27, 2023): @doddi321 It should work, example: ``` json [ { "Guid": "41372914-1838-4c67-916b-b9aacdd096ce", "UpdatedAt": "2023-01-14T15:16:17", "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/foo", "IgnoreCase": false } ] }, "Methods": [ "GET" ], "Params": [ { "Name": "test", "Matchers": [ { "Name": "LinqMatcher", "Pattern": "it.Length < 10" } ] } ] }, "Response": { "BodyDestination": "SameAsSource", "Body": "{ msg: \"Hello world!\"}" } } ] ```
Author
Owner

@StefH commented on GitHub (Jun 27, 2023):

https://github.com/WireMock-Net/WireMock.Net/pull/961

@StefH commented on GitHub (Jun 27, 2023): https://github.com/WireMock-Net/WireMock.Net/pull/961
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net#523