Hello! Is it possible to use templated responses w...
# help
m
Hello! Is it possible to use templated responses with java objects in wiremock-grpc-extension ? E.g with json you can do
Copy code
mockGreetingService.stubFor(
    method("greeting")
        .withRequestMessage(equalToJson("{ \"name\":  \"${json-unit.any-string}\" }"))
        .willReturn(
            jsonTemplate(
                "{ \"greeting\": \"Hello {{jsonPath request.body '$.name'}}\" }")));
How can templated responses be performed with java objects. The example in the docs only states
Copy code
mockGreetingService.stubFor(
    method("greeting")
        .withRequestMessage(equalToMessage(HelloRequest.newBuilder().setName("Tom")))
        .willReturn(message(HelloResponse.newBuilder().setGreeting("OK"))));
which doesn't let you 1. use any string to match the name - as per example one 2. access
request.body
in any way Is there a way to do this or is it a gap?
t
It’s not possible to combine these at the moment unfortunately. The JSON converter in the proto library does some kind of encoding conversion that breaks the templating. Not had a chance to investigate yet.
m
okay, thank you!