mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 14:20:29 +01:00
Can I include a modified datetime in the response via a JSON definition? #495
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @MichaelIDS on GitHub (Feb 24, 2023).
Originally assigned to: @StefH on GitHub.
I'm trying to add an hour to the current DateTime and include that new DateTime in the response.
I know I can get the current DateTime via
{{DateTime.Now}}But I can't see how I can manipulate this.
I wondered about using Handlebars and splitting the string, then using an each and if's to manipulate it, but I can't seem to nest the response value of
{{DateTime.Now}}into a handlebars expression.Is nesting
{{}}within each other across handlers not supported I take it, i.e. the inner customer handler for{{DateTime}}isn't completed and substituted before the result is passed to handlebars for the{{each}}to be processed by that library.EDIT: I originally misunderstood what Humanizer DateTime did and initially thought it could help with adding an hour to the time. hence the title and content change.
@StefH commented on GitHub (Feb 26, 2023):
This is not yet possible, I'm working on an update on the DynamicLinq Handlebars helper.
@StefH commented on GitHub (Mar 1, 2023):
https://github.com/WireMock-Net/WireMock.Net/pull/893
@StefH commented on GitHub (Mar 1, 2023):
@MichaelIDS
If you use version
1.5.17-ci-17109, you can now use DynamicLinq to manipulate e.g. DateTime or do other logic.Example mapping json:
And when calling the url:
http://localhost/data/1Results into response body:
@StefH commented on GitHub (Mar 8, 2023):
@MichaelIDS Did you have time to verify this?
@MichaelIDS commented on GitHub (Mar 9, 2023):
Unfortunately, I am still waiting to get time allocated to development/testing of these new WireMock features.
We haven't reached the point when we specifically need to do this, I was just looking ahead when I asked the question :)
@StefH commented on GitHub (Mar 9, 2023):
@MichaelIDS
No problem, I'll just merge the changes to master, and in the next days I'll create a new NuGet.
I'll close this issue and if you have another question, just raise a new issue.
@MichaelIDS commented on GitHub (Apr 3, 2023):
I know it's very late, but yes. the date modification works nicely, thanks. 👍