JsonPartialMatcher example 1 results in an error on server startup #441

Closed
opened 2025-12-29 15:23:50 +01:00 by adam · 1 comment
Owner

Originally created by @rosemaryehlers on GitHub (Aug 22, 2022).

Originally assigned to: @StefH on GitHub.

I copied example 1 from the JsonPartialMatcher wiki into a test.json static mapping file. When I start my wiremock docker container, I get the following error:

habits-mocks | 08/22/2022 01:11:07 [Error] : Static MappingFile : '/app/__admin/mappings/test.json' could not be read. This file will be skipped.

Only thing I've changed is the Guid. For reference, here is the copied file:

{
    "Guid": "3d76d96b-4d95-4a7d-b65d-2b0bbb575329",
    "Request": {
        "Path": {
            "Matchers": [
                {
                    "Name": "JsonPartialMatcher",
                    "Pattern": "/jsonpartialmatcher1"
                }
            ]
        },
        "Methods": [
            "post"
        ],
        "Body": {
            "Matcher": {
                "Name": "JsonMatcher",
                "Pattern": "{ \"test\": \"abc\" }"
            }
        }
    },
    "Response": {
        "StatusCode": 200,
        "Body": "{ \"result\": \"jsonpartialbodytest1\" }",
        "UseTransformer": false
    }
}

And here is a link to the wiki I copied it from: Json mapping option 1

Originally created by @rosemaryehlers on GitHub (Aug 22, 2022). Originally assigned to: @StefH on GitHub. I copied example 1 from the JsonPartialMatcher wiki into a `test.json` static mapping file. When I start my wiremock docker container, I get the following error: ``` habits-mocks | 08/22/2022 01:11:07 [Error] : Static MappingFile : '/app/__admin/mappings/test.json' could not be read. This file will be skipped. ``` Only thing I've changed is the Guid. For reference, here is the copied file: ``` json { "Guid": "3d76d96b-4d95-4a7d-b65d-2b0bbb575329", "Request": { "Path": { "Matchers": [ { "Name": "JsonPartialMatcher", "Pattern": "/jsonpartialmatcher1" } ] }, "Methods": [ "post" ], "Body": { "Matcher": { "Name": "JsonMatcher", "Pattern": "{ \"test\": \"abc\" }" } } }, "Response": { "StatusCode": 200, "Body": "{ \"result\": \"jsonpartialbodytest1\" }", "UseTransformer": false } } ``` And here is a link to the wiki I copied it from: [Json mapping option 1](https://github.com/WireMock-Net/WireMock.Net/wiki/Request-Matching-JsonPartialMatcher)
adam added the question label 2025-12-29 15:23:50 +01:00
adam closed this issue 2025-12-29 15:23:50 +01:00
Author
Owner

@StefH commented on GitHub (Aug 22, 2022):

@rosemaryehlers
The example was wrong.
For path, you can only use a string or matcher which implements IStringMatcher (which is fine for e.g. WildcardMatcher)

For the body, you can use a JsonPartialMatcher

"Body": {
            "Matcher": {
                "Name": "JsonPartialMatcher",
                "Pattern": "{ \"test\": \"abc\" }"
            }
        }
@StefH commented on GitHub (Aug 22, 2022): @rosemaryehlers The example was wrong. For path, you can only use a `string` or matcher which implements `IStringMatcher` (which is fine for e.g. WildcardMatcher) For the body, you can use a JsonPartialMatcher ``` json "Body": { "Matcher": { "Name": "JsonPartialMatcher", "Pattern": "{ \"test\": \"abc\" }" } } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#441