Hi team, this is my proxy template ```{ "priorit...
# wiremock-java
r
Hi team, this is my proxy template
Copy code
{
  "priority": 5,
  "request": {
    "method": "ANY",
    "urlPattern": "/example-data-status-app/.*",
  },
  "response": {
    "proxyBaseUrl": <http://testdata.dev.example.com>,
    "status": 200
  }
}
And I got following record
Copy code
{
  "request" : {
    "url" : "/example-data-status/services/v2/",
    "method" : "POST",
    "bodyPatterns" : [ {
      "equalToJson" : "{\"startDate\":\"2022-08-26T21:24:10.598Z\",\"endDate\":\"2024-08-26T21:24:10.598Z\",\"labels\":[]}",
      "ignoreArrayOrder" : true,
      "ignoreExtraElements" : true
    } ]
  },
  "response" : {
    "status" : 200,
  },
}
Is is possible to get record like
Copy code
{
  "request" : {
    "url" : "/example-data-status/services/v2/",
    "method" : "POST",
    "bodyPatterns" : [ {
      "equalToJson" : "{\"startDate\":\"2022-08-26T21:24:10.598Z\",\"endDate\":\"2024-08-26T21:24:10.598Z\",\"labels\":[]}",
      "ignoreArrayOrder" : true,
      "ignoreExtraElements" : false
    } ]
  },
  "response" : {
    "status" : 200,
  },
}
Due to the startDate attribute in record will expire and can not reuse. Thanks a lot guys
t
You can either manually edit the record after the recording or write a StubMappingTransformer that will automate this for you. One option if you want to keep the stub current is to enable templating and use the date helper to dynamically generate a date that is relative to now.
r
thanks for reply
Currently I am directly using standalone server to recording and mocking. Is it possible through json template to implement above? Thanks a lot!
@Tom
t
I’m not really clear what your question is. Can you elaborate?
r
Sure I directly use
Copy code
java -jar wiremock-standalone-3.9.1.jar --record-mappings
as recording mode to record the API request. In the mapping folder I will define the mapping proxy template json file. So in this way, is it possible to modify the json template file to complete above request, such as make the record's attribute "ignoreExtraElements" as false. Thanks a lot
t
So you’d like to modify the stub mappings automatically after the recording is complete?
r
Thanks for your reply. My current work flow is use
Copy code
java -jar wiremock-standalone-3.9.1.jar --record-mappings
to recording. My question is is it possible to through setup a custom json template file to make standalone to generate a recording's attribute"ignoreExtraElements" value as "false". Thanks a lot