-
-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Add support to recognise custom json media-types #211
Comments
Or define at the mapping that the request body should be parsed as String, Json or Bytes by using a new property at the body mapping named Using this new setting overrides the default Content-Type logic. Example {
"Guid": "debaf408-3b23-4c04-9d18-ef1c020e79f3",
"Request": {
"Path": {
"Matchers": [
{
"Name": "WildcardMatcher",
"Pattern": "/jsonbodytest2",
"IgnoreCase": true
}
]
},
"Methods": [
"post"
],
"Body": {
"ParseBodyAs": "Json",
"Matcher": {
"Name": "JsonMatcher",
"Pattern": {
"x": 42,
"s": "s"
}
}
}
},
"Response": {
"StatusCode": 200,
"Body": "{ \"result\": \"jsonbodytest2\" }"
}
} |
i am very interested in this new feature ( when do you expect to release a new version to nuget that includes this functionality ? is it on a branch that i could take a look at? |
I'll take a look and start building this new functionality. |
that would be great, thanks! |
@StefH is there a way to specify |
Hello @lesnes and @alefranz, In short:
Please have a look to see if this will solve your questions. |
In the current version I believe sometimes you only have the body as bytes. |
The property The Content-Type is not used anymore in the logic now. The real logic is done with the I can implement |
Ok, I guess I didn't really get the gist of the PR. I'll have a better look. Do you publish the PR builds as prerelease on myget by any chance? |
Added a preview version to MyGet |
wow, that was quick. great job! looks like it would suit my purposes |
@alefranz PR build is published at https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net / https://www.myget.org/F/wiremock-net/api/v3/index.json Can you please test this one ? |
i've tested my usage requirement for |
Good news. @alefranz : If you can confirm this issue and also the other issue; I can create a new official build. |
Apologies, I will be able to test only on Monday. |
Nice, now the mapping has the body as json, however when I save the mappings with |
Ah, I did not think of that. Saving all 3 would be an additional option, which will be available in the next version. |
but in my scenario with |
@alefranz 1] 2] 3] "Body": "{ \"things\": [ { \"name\": \"RequiredThing\" }, { \"name\": \"Wiremock\" } ] }",
"BodyAsJson": {
"things": [
{
"name": "RequiredThing"
},
{
"name": "Wiremock"
}
]
},
"BodyAsBytes": "eyAidGhpbmdzIjogWyB7ICJuYW1lIjogIlJlcXVpcmVkVGhpbmciIH0sIHsgIm5hbWUiOiAiV2lyZW1vY2siIH0gXSB9", This I can update. |
This is my workflow:
ProxyAndRecordSettings = new ProxyAndRecordSettings
{
Url = originaUrl,
SaveMapping = true,
SaveMappingToFile = false
};
All this responses are json but I have custom media types The purpose of this is to automatically generate the mappings to load in my tests. My goal is to have only |
I see your point. See https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions for details on MyGet |
@alefranz : did you have time to test the latest version on MyGet? |
Apologies for the delay. It works like a charm! Thanks! |
@alefranz Are you sure you tested the 1.0.4.18-ci-1349 (or later) MyGet version ? |
Yes, I've tested 1.0.4.18-ci-1349 and the saved mapping contains only the BodyAsJson as desired |
Thank you! |
Hi,
This is a feature request to add support to recognise as json custom media types:
e.g.
application/vnd.*+json
.I think it could be either match on this pattern (or just +json) or open the
BodyParser
so it can be customized or media-types can be registered.Specifically I'm after the ability to correctly save the payload as json when saving the auto generated mappings (when capturing as proxy).
If you are open to the idea I can contribute a PR for this.
The text was updated successfully, but these errors were encountered: