wiremock / wiremock/wiremock.org
Issue on Response Templating
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 12
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
Page
/docs/response-templating/
Details
I am using gradle dependency: implementation 'com.github.tomakehurst:wiremock:2.27.2'
My JSON stub mapping is calling a POST URL using proxyBaseUrl and sending the response to transformers (I am writing my own transformer class by extending ResponseTransformer to dynamically change the response based on the response from proxy URL).
JSON Stub:
Issue:
- I can see the response from proxyBaseUrl as HTTP 200, but when I try printing the body using response.getBodyAsString(), it returns a string in unreadable format.
200 response:
response.getBodyAsString():
How can I read this response in readable format (preferably json), to change the response dynamically using transformer functionality.
- response.getBody() method returns a byte array.
response.getBody():
Tried decoding the byte array returned using all StandardCharsets and
new String(response.getBody(), response.getHeaders().getContentTypeHeader().charset());
How can I convert this byte array in a readable format. Thank you in anticipation of a solution.
Suggested Edits
No response
References
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at /docs/response-templating/ and review the ResponseTransformer guidance alongside the WireMock 2.27.2 behavior described. Clarify the documented handling of proxied response bytes, charset, and JSON conversion, then verify the page answers both getBodyAsString() and getBody() questions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100