wiremock / wiremock.org

WireMock website, powered by Jekyll. Contributions are welcome!
https://wiremock.org/
MIT License
11 stars 49 forks source link

outdated documentation for ResponseTemplateTransformer #210

Closed jarekczek closed 10 months ago

jarekczek commented 11 months ago

Summary

I am facing a task of upgrading from wiremock 2.26. I have problems with creating ResponseTemplateTransformer. Seems like the Response Templating section uses ResponseTemplateTransformer.Builder, which is now removed. Could you please document the way this transformer should be created?

References

No response

oleg-nenashev commented 11 months ago

Thanks for reporting @jarekczek . It went missing in the 3.0 review

TomerPacific commented 10 months ago

Hi @oleg-nenashev, I'd like to help out. How can I begin this task?

oleg-nenashev commented 10 months ago

@TomerPacific thanks for the interest. I would recommend exploring this functionality in WireMock 2 by following the existing docs, and then updating to WireMock 3 and fixing the documentation accordingly

TomerPacific commented 10 months ago

Thanks @oleg-nenashev for the quick response. I've done some digging and have found out that the API changed drastically. Since I am unfamiliar with WireMock, it is kind of hard for me to connect all the pieces together. Here is what I have so far:

Since there is no javadoc at all in the project, I'm having trouble connecting the dots here.

This is what I have written so far in the relevant documentation place:

If you want to add permitted extensions to your rule, then you can use the ResponseTemplateTransformer when constructing the response template extension.

The ResponseTemplateTransformer accepts four arguments:

  1. The TemplateEngine
  2. If templating can be applied globally
  3. The FileSource
  4. A list of TemplateModelDataProviderExtension objects
@Rule
public WireMockRule wm = new WireMockRule(options()
        .dynamicPort()
        .withRootDirectory(defaultTestFilesRoot())
        .extensions(new ResponseTemplateTransformer(
              getTemplateEngine(),
              options.getResponseTemplatingGlobal(),
              getFiles(),
              templateModelProviders
            )
        )
);

Could you help me out by explaining these arguments?

TomerPacific commented 10 months ago

@oleg-nenashev - Can you provide some feedback regarding what I wrote above? I opened a draft PR.

oleg-nenashev commented 10 months ago

Hi. Catching up with my backlog, will respond asap. Please note the better way to get more feedback is bringing it up in #help-contributing because there are more folks who can respond

jarekczek commented 10 months ago

In the example there is a method getTemplateEngine(). Where does it come from?

Balaalwayz commented 6 months ago

@jarekczek , did you find an answer. I see a defaultTemplateEngine() static method in TemplateEngine class.