Slackbot
01/20/2024, 1:45 AMLee Turner
01/21/2024, 4:04 PMKumaresan Sithambaram
01/21/2024, 10:03 PMstubMappingId
. So, Is there a way I can find (GET service
) to get current stubMappingId
? so that based on stubMappingId
, i can update or overwrite the existing stub?Lee Turner
01/22/2024, 9:12 AMPUT
endpoint.
To do this you could call the GET
mappings endpoint and then figure out the id from there. This might not be as easy as it sounds depending on how many mappings you have.
Another option is to specify the id in the mappings file so wiremock uses that one instead of generating one for you. This way you would know the id upfront and wouldn't need to call the GET
endpoint. Each option has its pros and cons.
If you haven't seen it there is a full reference on the admin API here - https://wiremock.org/docs/standalone/admin-api-reference/
An example of a mapping with and id is:
{
"id": "711f58fd-d436-4ec1-839e-a1e73dc2d61d",
"name": "orders",
"request": {
"url": "/orders",
"method": "GET"
},
"response": {
"status": 200,
"jsonBody": [
{
"id": 1,
"name": "order 1"
},
{
"id": 2,
"name": "order 2"
}
],
"headers": {
"Content-Type": "application/json"
}
}
}
You can then call the PUT
endpoint with the id - http://localhost:8080/__admin/mappings/711f58fd-d436-4ec1-839e-a1e73dc2d61dKumaresan Sithambaram
01/22/2024, 5:02 PMKumaresan Sithambaram
01/23/2024, 9:48 PMLee Turner
01/24/2024, 10:13 AMPUT
endpoint with the mapping id to do any updates?
Sorry if I am not quite understanding your requirementsKumaresan Sithambaram
01/24/2024, 4:31 PMPOST
(create) new stubs creates and persist in mappings folder. But, the later time if the developer wants to update the same stub, the option is call the PUT
(update) service. But, in order to update the same existing stub file and overwrite in the mapping folder, I have to identify the stub/mapping ID. Hope it is clear till now. Because the wiremock originally created the stub file name in the mappings folder with the stub ID. Until i do not know the stub ID, i can not go overwrite the existing stub file's content with latest content. So, question how do i isolate that particular stub ID in order call the PUT
(update) service?Kumaresan Sithambaram
01/25/2024, 6:18 PMLee Turner
01/26/2024, 9:17 AMTom
01/26/2024, 10:12 AM.filenameTemplate(…)
on the config object or --filename-template
from the CLILee Turner
01/26/2024, 10:13 AM