https://linen.dev logo
#help
Title
d

Danny Paniagua

04/14/2023, 3:23 PM
Hey all - does anyone know if it possible to use response templating for the status field in responses? Wondering if I'm doing something that isn't supported atm or if I'm just using incorrect syntax somewhere. Basically have something like this
Copy code
"response": {
    "status": "{{#eq (jsonPath request.body '$.token') 'happy-path-token'}}200{{else}}500{{/eq}}",
    "headers": {
      "Content-Type": "application/json"
    },
  }
and wiremock is throwing an error
Copy code
Cannot deserialize value of type `int` from String "{{#eq (jsonPath request.body '$.paymentToken') 'happy-path-payment-token'}}200{{else}}500{{/eq}}": not a valid `int` value
I know I can just make separate mapping stubs for a 200 and 500 response, but just sort of playing around with the tech atm 🙂
a

Aaron

04/14/2023, 3:25 PM
IIRC the answer is no, because the response template needs a string and WireMock can’t work that back into an Int for the status code. Could use a custom response definition transformer though
d

Danny Paniagua

04/14/2023, 3:25 PM
Gotcha, thanks for the quick reply! That was what it seemed like when I was googling stuff, but wasn't sure if I was just searching wrong things
a

Aaron

04/14/2023, 3:26 PM
Yeah, I could be mistaken but I feel like I’ve encountered this before and couldn’t work it out.
2 Views