mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
Using WireMock in integration tests does not pick up the SerializerSettings defined in the StartUp #427
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 @ghost on GitHub (Jul 27, 2022).
In the Startup:
The integration test custom WebApplicationFactory (which is then used with the Startup of course):
The issue is then that the WireMockServer does not pick up the json settings (null ignore) set in the startup (I see null fields in the wireMockServer.MappingModels, whereas my API does not serialize nulls, as expected from startup settings)
I've found a way around it but I would like to know if it's possible for WireMockServer to pick up the json settings defined in startup
I did this just after the
const string urlline:@StefH commented on GitHub (Jul 28, 2022):
Hello @FredCni.
Please note that WireMockServer.Start does not pick up any dependency injection defined like
AddNewtonsoftJson.The only possible solution for you issue is that I update the settings to include a new setting
JsonSerializerSettingswhich you can override as you like.@StefH commented on GitHub (Aug 1, 2022):
Hello @FredCni,
Did you have time to reflect on this idea?
@ghost commented on GitHub (Aug 1, 2022):
Thanks for your reply, much appreciated.
It would be nicer to have this parameter in the init settings, because it would be more explicit than the current way
(
JsonConvert.DefaultSettings)Whether you add it or not, the doc should stress that WireMock serializing settings should be aligned on the serializer settings of the mocked system.
If you don't add it: the doc should point to
JsonConvert.DefaultSettingsas the "how to"@StefH commented on GitHub (Aug 1, 2022):
Can you elaborate what you mean by
this parameter in the init settings? Which init-settings you mean?@ghost commented on GitHub (Aug 2, 2022):
Oh, I meant please do as you suggested:
Pls also update the doc as I suggested.
@StefH commented on GitHub (Aug 9, 2022):
@FredCni
Just to clarify : when do you want that your custom JsonSerializerSettings are used?
@StefH commented on GitHub (Aug 15, 2022):
@FredCni
See this preview version (
1.5.3-ci-16370) where you can provide a different JsonConverter when usingWithBody:For implementations for IJsonConverter, see https://github.com/StefH/JsonConverter.
(how to install preview version: see https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions)
@StefH commented on GitHub (Aug 24, 2022):
Solved with
https://github.com/WireMock-Net/WireMock.Net/issues/786
A new NuGet will be released soon.
@ghost commented on GitHub (Aug 24, 2022):
Was caught with things, so did not take the time to follow up, but you did 👍
Thank you very much.
I'll try the new nuget as soon as released.