Dynamic webhook setup. #332

Closed
opened 2025-12-29 15:21:07 +01:00 by adam · 7 comments
Owner

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.

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.
adam added the question label 2025-12-29 15:21:07 +01:00
adam closed this issue 2025-12-29 15:21:07 +01:00
Author
Owner

@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

@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
Author
Owner

@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.

@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.
Author
Owner

@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 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.
Author
Owner

@StefH commented on GitHub (Feb 2, 2021):

Also another option would be that you hook on the logging? Because the logging also shows the request/response?

@StefH commented on GitHub (Feb 2, 2021): Also another option would be that you `hook` on the logging? Because the logging also shows the request/response?
Author
Owner

@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.

@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.
Author
Owner

@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

@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
Author
Owner

@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.

@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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#332