amar1104
08/07/2024, 9:09 AMException in thread "main" com.github.tomakehurst.wiremock.standalone.MappingFileException: Error loading file /Users/amarnadh.m/Documents/mappings/createUser.json:
'matchesJsonSchema' expected value cannot be null
at com.github.tomakehurst.wiremock.standalone.JsonFileMappingsSource.loadMappingsInto(JsonFileMappingsSource.java:123)
at com.github.tomakehurst.wiremock.core.WireMockApp.loadMappingsUsing(WireMockApp.java:248)
at com.github.tomakehurst.wiremock.core.WireMockApp.loadDefaultMappings(WireMockApp.java:242)
at com.github.tomakehurst.wiremock.core.WireMockApp.<init>(WireMockApp.java:123)
at com.github.tomakehurst.wiremock.WireMockServer.<init>(WireMockServer.java:71)
Attached the stub below. Can you please let me know how to resolve this issue?amar1104
08/07/2024, 9:12 AM{
"mappings": [
{
"request": {
"method": "POST",
"url": "/api/v1/user",
"bodyPatterns": [
{
"not": {
"matchesJsonSchema": {
"type": "object",
"required": [
"firstName",
"lastName",
"username",
"email"
],
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"username": {
"type": "string"
},
"email": {
"type": "string"
},
"phoneNumbers": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
]
},
"response": {
"status": 400,
"headers": {
"Content-Type": "application/json"
},
"body": "{\"error\": \"Bad Request\"}"
},
"priority": 1
},
{
"request": {
"method": "POST",
"url": "/api/v1/user"
},
"response": {
"status": 201,
"headers": {
"Content-Type": "application/json"
},
"body": "{\"id\":\"{{randomInt lower=1 upper=20000}}\",\"username\":\"{{jsonPath request.body '$.username'}}\",\"firstName\":\"{{jsonPath request.body '$.firstName'}}\",\"lastName\":\"{{jsonPath request.body '$.lastName'}}\",\"email\":\"{{jsonPath request.body '$.email'}}\", \"phoneNumbers\": {{#if (jsonPath request.body '$.phoneNumbers')}}{{jsonPath request.body '$.phoneNumbers'}}{{else}}[]{{/if}}\n}",
"transformers": [
"response-template"
]
},
"postServeActions": [
{
"name": "recordState",
"parameters": {
"context": "{{jsonPath response.body '$.username'}}",
"name": "userState",
"state": {
"fullBody": "{{{jsonPath response.body '$'}}}"
}
}
}
],
"priority": 2
}
]
}
java -cp "wiremock-state-extension-standalone-0.2.1.jar:~/Downloads/wiremock-standalone-3.9.1.jar" wiremock.Run --port 8181 --verbose
Dirk Bolte
08/07/2024, 9:29 AMamar1104
08/07/2024, 9:44 AMNo extension was found named "recordState"
starting wiremock with: java -cp wiremock-state-extension-standalone-0.8.0.jar:Downloads/wiremock-standalone-3.9.1.jar wiremock.Run --global-response-templating --port 8181 --verbose
amar1104
08/07/2024, 9:50 AMDirk Bolte
08/07/2024, 9:52 AMamar1104
08/07/2024, 10:01 AMDirk Bolte
08/07/2024, 10:02 AMamar1104
08/07/2024, 2:38 PM"list": {
"addLast": {
"fullBody": "{{{jsonPath response.body '$'}}}"
}
}
How to delete state using deleteWhere? I'm trying this
{
"name": "deleteState",
"parameters": {
"list": {
"deleteWhere": {
"property": "username",
"value": "{{request.path.username}}"
}
},
"context": "user-list"
}
}
I have also tried fullBody.username {{fullBody.username}} too. None of them seems to be deleting from the stateDirk Bolte
08/07/2024, 2:43 PM"list": {
"addLast": {
"username": {{jsonPath request.body '$.username'}}
"fullBody": "{{{jsonPath response.body '$'}}}"
}
}
amar1104
08/07/2024, 2:47 PMamar1104
08/07/2024, 2:48 PMThe evaluation order of listeners within a stub as well as across stubs is not guaranteed.
Is there any reason for this especially within the stub.Dirk Bolte
08/07/2024, 3:32 PMamar1104
08/07/2024, 4:02 PM