Skip to content

[3.0.0] Custom ResponseTemplateTransformer gets overwritten by default implementation #2349

Description

@alex-martel

Proposal

In Wiremock 2.35 I have the following external file;

file.json

[
    {
        "id": "theID",
        "time": {{now offset='2 hours' format='epoch'}}
    }
]

with the following code;

        WireMockConfiguration config = new WireMockConfiguration().extensions(new ResponseTemplateTransformer(true))
                .port(9090).fileSource(new ClasspathFileSource("src/test/resources/jsonfiles/"));
        wireMockServer = new WireMockServer(config);

in 3.0 the code change to this;

        WireMockConfiguration config = new WireMockConfiguration();
        FileSource fs = new ClasspathFileSource("src/test/resources/jsonfiles/");
        config = config.port(9090).fileSource(fs)
                .extensions(new ResponseTemplateTransformer(TemplateEngine.defaultTemplateEngine(), true, fs,
                        Collections.emptyList()));
        wireMockServer = new WireMockServer(config);

in the json returned by wiremock, the {{now offset='2 hours' format='epoch'}} is not replaced thus leading to wrong json format + data. I must say I also find it odd api wise to pass the FileSource to both the config and the ResponseTemplateEngine.

Reproduction steps

have wiremock returning a classpathfilesource like the above and see the template not being replaced.

References

Relates to; wiremock/wiremock.org#157

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions