mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
JsonMatcher should serialize enum as text if such attribute is defined #426
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 8, 2022).
Describe the bug
The JsonMatcher does not respect the enum serialization attributes
Expected behavior:
The matcher should match on a json containing the enum as a string instead of a number
Test to reproduce
In the WireMock Given definition:
The request won't be matched because the json matcher (see its private _valueAsJToken) tries to match on MyEnum = 0, instead of MyType1
Other related info
What serializer is used? Is there a way to tweak it so it serializes enums as strings?
@StefH commented on GitHub (Jul 8, 2022):
@FredCni
Can you make a full working example project, or a PullRequest with a new unit-test which demonstrates this error?
@StefH commented on GitHub (Jul 9, 2022):
#770
@StefH commented on GitHub (Jul 9, 2022):
@FredCni
The attribute is wrongly placed. Use this:
@ghost commented on GitHub (Jul 11, 2022):
Thank you, that fixed it!