Fluent API for RestClient MappingModel creation
See original GitHub issueIs your feature request related to a problem? Please describe.
I’m thinking about using WireMock as a container to run alongside my application during tests, and as far as I searched, looks like I have to create a mapping by instantiating a new MappingModel
directly.
Describe the solution you’d like I think it would be really useful for users to have an experience similar to the fluent API to used to create requests when WireMock is used on the same process. I am no expert on the library but I imagine there would be some limitations, but for simple cases like matching a request and building a response, it would be really useful, since I wouldn’t have to learn two ways to configure mappings.
Describe alternatives you’ve considered Build the mapping model directly.
Is your feature request supported by WireMock (java version)? Please provide details. I’m not familiar with the java version, but as far as I researched, I couldn’t find anything like that yet.
Additional context I don’t if this is something that would be interesting for the main library or maybe it would be something that the creators would want the community to develop. But if this is something that is planned or wanted, I would be glad to help as I can. But as I said, I’m no expert and I’m not sure if I would be able to cover every possible scenario the current fluent API has.
I’m building a simple example and I’ll post here when I make some progress.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
You can work-around this problem by using a
FluentBuilder.ResponseModelBuilder()
and then assign the value toWithResponse(...)
To support your scenario, I’ve to see if I can update the FluentBuilder. Can you create a new issue here? --> https://github.com/StefH/FluentBuilder
And for now, I’ll merge the PR and close this issue.
In case I can implement your scenario in the FluentBuilder project, I’ll post an update here and release a new WireMock.Net NuGet.
Apologies for taking so long, I’ve been a bit busy. I took a look at the most recent version of the CI build, the API looks a little different, I don’t know if it made a lot of difference. My simplest setup looked like this:
With the modification, it looks like this:
Maybe the MappingModelBuilder
WithRequest
andWithResponse
methods could have an overload that asks for anAction<RequestModelBuilder>
andAction<ResponseModelBuilder>
? That way it could look like this: