https://linen.dev logo
#general
Title
# general
v

Victor Baulac

12/01/2023, 9:54 AM
Good Morning everybody. I am trying to do something similar to https://wiremock.org/docs/response-templating/#json-2 (using request.pathSegments in bodyFileName), but I endup with
NotFoundException: Not found in blob store: files/{{request.pathSegments.[2]}}
It is not intepreting my variable between {{ }} but considering it as a String. To me it looks like I am doing exactly what the documentation states. Am I missing something ? Here is my complete JSON :
{
"request": {
"method": "GET",
"urlPathPattern": "/blabla/adc/golden/.*"
},
"response": {
"status": 200,
"bodyFileName": "files/{{request.pathSegments.[3]}}",
"headers": {
"Content-Type": "image/png"
}
}
}
βœ… 1
o

Oleg Nenashev

12/01/2023, 10:05 AM
Hi. Did you enable global templating?
v

Victor Baulac

12/01/2023, 10:06 AM
Hi. Probably not, I didn't know that was a thing. I discovered WireMock yesterday. I'll search thoses keywords thx !
Not sure how I do that in JSON... My context : WireMock standalone docker, with JSON's in the mapping directory
Okay you answered helped me a lot ! I would think the documentation is missing this line ""transformers": ["response-template"]," For the JSON code snippet though.
Thank you πŸ™‚
o

Oleg Nenashev

12/01/2023, 10:09 AM
Or `--global-response-templating`: Render all response definitions using Handlebars templates.
the CLI option ^
v

Victor Baulac

12/01/2023, 10:09 AM
when launching my docker ?
o

Oleg Nenashev

12/01/2023, 10:09 AM
yes
v

Victor Baulac

12/01/2023, 10:09 AM
thx πŸ˜‰
o

Oleg Nenashev

12/01/2023, 10:11 AM
We do not document enabling templates in all the examples, but probably we should add a
requirements
warning sign to those samples that need templating to be enabled. Later we would use the same engine for extension requirements, e.g. gRPC or Faker. FYI @Tom I could add it to the MkDocs Engine PR
πŸ‘ 1
t

Tom

12/01/2023, 11:05 AM
Templating (local) is enabled by default from 3.2.0 onwards
If there are doc snippets where we’re not including the transformer element in the JSON, we should definitely add that
πŸ‘ 1
o

Oleg Nenashev

12/02/2023, 11:25 AM
Hmm, I thought that all transformers will be enabled by default with the global flag
9 Views