mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
Dynamic webhook setup. #332
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 @ShaunJahn on GitHub (Feb 1, 2021).
Tyring to create a .Net mock server application, that reads a swagger JSON file. Once an endpoint is mocked and return that response is then sent to a webhook. Not sure how to configure the endpoint for swagger to trigger a webhook call back.
@StefH commented on GitHub (Feb 1, 2021):
I think that want to investigate "WireMock.Net.OpenApiParser".
See this example
https://github.com/WireMock-Net/WireMock.Net/tree/master/examples/WireMock.Net.OpenApiParser.ConsoleApp
@ShaunJahn commented on GitHub (Feb 1, 2021):
Thank you for the reply. I manage to integrate the JSON file from swagger as per this link.
I'm trying to create a callback on every mocked call to trigger a function that sends a payload to a webhook.
For example, when creating a mock instance manually I'm able to use this:
.WithCallback(callbackHandler)I'm trying to set this up for each swagger endpoint that gets read from the JSON file. As this is read dynamically I'm not sure how to assign the callback.
@StefH commented on GitHub (Feb 1, 2021):
I see.
What you want to to loop all automatic generated mappings and then assign .WithCallback
I'm not sure if that's possible. I'll think about it.
@StefH commented on GitHub (Feb 2, 2021):
Also another option would be that you
hookon the logging? Because the logging also shows the request/response?@ShaunJahn commented on GitHub (Feb 2, 2021):
Sadly I have tried doing this but still need the webhook to trigger. If you have any ideas on how to achieve this still ill be open to suggestions.
@StefH commented on GitHub (Feb 2, 2021):
Did you try making an own version from the logger?
https://github.com/WireMock-Net/WireMock.Net/blob/master/examples/WireMock.Net.WebApplication.NETCore3/WireMockService.cs#L18
@ShaunJahn commented on GitHub (Feb 2, 2021):
@StefH Thank you, that really helped and I manage to sort this question out.
Thanks again for your help.