Need ability to add custom ResponseMessageTransformers #179

Closed
opened 2025-12-29 08:23:30 +01:00 by adam · 7 comments
Owner

Originally created by @muzammilkm on GitHub (Jun 16, 2019).

Version: 1.0.19.

There is no way to add custom Response Message Transforms apart from using built in HandleBars which is also limited, I am trying generate response based on current datetime and also need to do some calculation via mapping file.

So could you please add way to extend Response Message Transforms like wiremock does Extending WireMock or if HandlebarsContext is accessible so, that we could Register custom transformation that are needed Registering Helpers ?

Originally created by @muzammilkm on GitHub (Jun 16, 2019). Version: 1.0.19. There is no way to add custom Response Message Transforms apart from using built in HandleBars which is also limited, I am trying generate response based on current datetime and also need to do some calculation via mapping file. So could you please add way to extend Response Message Transforms like wiremock does [Extending WireMock](http://wiremock.org/docs/extending-wiremock/) or if HandlebarsContext is accessible so, that we could Register custom transformation that are needed [Registering Helpers](https://github.com/rexm/Handlebars.Net#registering-helpers) ?
adam added the featurequestion labels 2025-12-29 08:23:30 +01:00
adam closed this issue 2025-12-29 08:23:30 +01:00
Author
Owner

@StefH commented on GitHub (Jun 17, 2019):

  1. You are correct, extending handlebars is not yet supported, I'll take a look.

  2. If you just want custom C# code, this is also possible using:

server
                .Given(Request.Create().WithPath("/myendpoint").UsingAnyMethod())
                .RespondWith(Response.Create()
                    .WithStatusCode(500)
                    .WithBody(requestMessage =>
                    {
                       // custom code here....
                        return JsonConvert.SerializeObject(new
                        {
                            Message = "Test error"
                        });
                    })
);
@StefH commented on GitHub (Jun 17, 2019): 1. You are correct, extending handlebars is not yet supported, I'll take a look. 2. If you just want custom C# code, this is also possible using: ``` c# server .Given(Request.Create().WithPath("/myendpoint").UsingAnyMethod()) .RespondWith(Response.Create() .WithStatusCode(500) .WithBody(requestMessage => { // custom code here.... return JsonConvert.SerializeObject(new { Message = "Test error" }); }) ); ```
Author
Owner

@muzammilkm commented on GitHub (Jun 17, 2019):

Yes, Right now, i am using inline style along json mapping till a new version is available.

@muzammilkm commented on GitHub (Jun 17, 2019): Yes, Right now, i am using inline style along json mapping till a new version is available.
Author
Owner

@StefH commented on GitHub (Jun 18, 2019):

Settings class will be extended with:

public Action<IHandlebars, IFileSystemHandler> HandlebarsRegistrationCallback { get; set; }

Is this enough?

@StefH commented on GitHub (Jun 18, 2019): Settings class will be extended with: ``` xml public Action<IHandlebars, IFileSystemHandler> HandlebarsRegistrationCallback { get; set; } ``` Is this enough?
Author
Owner

@muzammilkm commented on GitHub (Jun 18, 2019):

Thanks that work.

@muzammilkm commented on GitHub (Jun 18, 2019): Thanks that work.
Author
Owner

@StefH commented on GitHub (Jun 19, 2019):

You can try the preview version:

  • WireMock.Net 1.0.21-ci-11460
  • WireMock.Net.StandAlone 1.0.21-ci-11460

Also, if you think your Handlebars extension is useful for common usage, please share the code.

@StefH commented on GitHub (Jun 19, 2019): You can try the preview version: - WireMock.Net 1.0.21-ci-11460 - WireMock.Net.StandAlone 1.0.21-ci-11460 Also, if you think your Handlebars extension is useful for common usage, please share the code.
Author
Owner

@muzammilkm commented on GitHub (Jun 20, 2019):

Thanks you quick turn around. Sure, if some thing is generic nature, will certainly share it.

@muzammilkm commented on GitHub (Jun 20, 2019): Thanks you quick turn around. Sure, if some thing is generic nature, will certainly share it.
Author
Owner

@StefH commented on GitHub (Jun 20, 2019):

Also closing this one.

@StefH commented on GitHub (Jun 20, 2019): Also closing this one.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net#179