Why WireMock.net is not compatible with stubs from WireMock.org #283

Closed
opened 2025-12-29 15:19:42 +01:00 by adam · 12 comments
Owner

Originally created by @Ppiwow on GitHub (Jul 20, 2020).

Originally assigned to: @StefH on GitHub.

Hi,

We wanted to use stubs generated for WireMock.org (spirng contract testing). It seems that they are incompatible or we are using it in wrong way.

Example from WireMock.net: https://github.com/bredah/csharp-wiremock/blob/master/NetCore.2.2/Mock/__admin/mappings/example.json

Example of stub for WireMock.org:

{
  "id" : "f34b38df-059b-401d-a391-2c7e1b21258d",
  "request" : {
    "url" : "/api/Customers",
    "method" : "GET",
    "headers" : {
      "Content-Type" : {
        "equalTo" : "application/json"
      }
    }
  },
  "response" : {
    "status" : 200,
    "body" : "[{\"firstName\":\"Stub1\",\"lastName\":\"Kowalski\"},{\"firstName\":\"Stub2\",\"lastName\":\"Kowalski\"},{\"firstName\":\"Stub3\",\"lastName\":\"Nowak\"},{\"firstName\":\"Stub4\",\"lastName\":\"Nowak\"}]",
    "headers" : {
      "Content-Type" : "application/json; charset=utf-8"
    },
    "transformers" : [ "response-template" ]
  },
  "uuid" : "f34b38df-059b-401d-a391-2c7e1b21258d"
}

Do you have any converter?

Originally created by @Ppiwow on GitHub (Jul 20, 2020). Originally assigned to: @StefH on GitHub. Hi, We wanted to use stubs generated for WireMock.org (spirng contract testing). It seems that they are incompatible or we are using it in wrong way. Example from WireMock.net: https://github.com/bredah/csharp-wiremock/blob/master/NetCore.2.2/Mock/__admin/mappings/example.json Example of stub for WireMock.org: ``` json { "id" : "f34b38df-059b-401d-a391-2c7e1b21258d", "request" : { "url" : "/api/Customers", "method" : "GET", "headers" : { "Content-Type" : { "equalTo" : "application/json" } } }, "response" : { "status" : 200, "body" : "[{\"firstName\":\"Stub1\",\"lastName\":\"Kowalski\"},{\"firstName\":\"Stub2\",\"lastName\":\"Kowalski\"},{\"firstName\":\"Stub3\",\"lastName\":\"Nowak\"},{\"firstName\":\"Stub4\",\"lastName\":\"Nowak\"}]", "headers" : { "Content-Type" : "application/json; charset=utf-8" }, "transformers" : [ "response-template" ] }, "uuid" : "f34b38df-059b-401d-a391-2c7e1b21258d" } ``` Do you have any converter?
adam added the question label 2025-12-29 15:19:42 +01:00
adam closed this issue 2025-12-29 15:19:42 +01:00
Author
Owner

@StefH commented on GitHub (Jul 20, 2020):

Hello @Ppiwow,

I'm sorry for the confusion, this project does indeed use a different JSON mapping file. The mappings are similar as idea, but the content differs.

See this youtube for some info:
https://youtu.be/IJa6DyJOxzk?t=436

@StefH commented on GitHub (Jul 20, 2020): Hello @Ppiwow, I'm sorry for the confusion, this project does indeed use a different JSON mapping file. The mappings are similar as idea, but the content differs. See this youtube for some info: https://youtu.be/IJa6DyJOxzk?t=436
Author
Owner

@StefH commented on GitHub (Sep 6, 2020):

@Ppiwow Does this answer your question, or do you need more help?

@StefH commented on GitHub (Sep 6, 2020): @Ppiwow Does this answer your question, or do you need more help?
Author
Owner

@Ppiwow commented on GitHub (Sep 6, 2020):

yes, but decission is really strange. standarization... specially if you were copying idea you could decide to make it compatible... this is json so easy to be compatible

@Ppiwow commented on GitHub (Sep 6, 2020): yes, but decission is really strange. standarization... specially if you were copying idea you could decide to make it compatible... this is json so easy to be compatible
Author
Owner

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

Hello @Ppiwow, I understand your statement, however when starting this project, I already had to deviate from some concepts from WireMock.Java so that resulted in another JSON Mapping file.

Maybe I'll create a converter some day, but not planned for short time.

@StefH commented on GitHub (Feb 18, 2021): Hello @Ppiwow, I understand your statement, however when starting this project, I already had to deviate from some concepts from WireMock.Java so that resulted in another JSON Mapping file. Maybe I'll create a converter some day, but not planned for short time.
Author
Owner

@rodrigoramos commented on GitHub (Aug 31, 2021):

Hi there! I have same problem here. We're creating a project which contains more than .NET technology (Python and Java) and it has been difficult to share those mappings across the projects.

Actually, that might invalidate the use of this marvelous tool at all.

Is it possible to help to create some kind of "importer" or something like the converter that you mentioned above?

@rodrigoramos commented on GitHub (Aug 31, 2021): Hi there! I have same problem here. We're creating a project which contains more than .NET technology (Python and Java) and it has been difficult to share those mappings across the projects. Actually, that might invalidate the use of this marvelous tool at all. Is it possible to help to create some kind of "importer" or something like the converter that you mentioned above?
Author
Owner

@StefH commented on GitHub (Aug 31, 2021):

@Ppiwow and @rodrigoramos
Can you help me by providing the model (Java) and the JSON file which the current wiremock.org uses?

And what would preferred?

  • a separate tool to convert the json from wiremock.org to this one?
  • an import / read wiremock.org mapping file capability?

(Note that a 100% match will never be possible...)

@StefH commented on GitHub (Aug 31, 2021): @Ppiwow and @rodrigoramos Can you help me by providing the model (Java) and the JSON file which the current wiremock.org uses? And what would preferred? - a separate tool to convert the json from wiremock.org to this one? - an import / read wiremock.org mapping file capability? (Note that a 100% match will never be possible...)
Author
Owner

@rodrigoramos commented on GitHub (Sep 9, 2021):

Hi @StefH! Thanks for your answer. IMO, I'd preferred an "import/read" capability.

I cannot share exactly the models that I'm working on (company's policy) but I can share some samples that I created in order to understand the Playback/Recording functionality.

GET Sample

{
  "id" : "ef53ea56-f118-4b3a-8c69-a9484851d99a",
  "name" : "weatherforecast",
  "request" : {
    "url" : "/WeatherForecast",
    "method" : "GET"
  },
  "response" : {
    "status" : 200,
    "body" : "[{\"date\":\"2021-09-09T20:44:48.0992639-03:00\",\"temperatureC\":51,\"temperatureF\":123,\"summary\":\"Hot\"},{\"date\":\"2021-09-10T20:44:48.0992692-03:00\",\"temperatureC\":34,\"temperatureF\":93,\"summary\":\"Mild\"},{\"date\":\"2021-09-11T20:44:48.0992696-03:00\",\"temperatureC\":43,\"temperatureF\":109,\"summary\":\"Sweltering\"},{\"date\":\"2021-09-12T20:44:48.0992698-03:00\",\"temperatureC\":46,\"temperatureF\":114,\"summary\":\"Cool\"},{\"date\":\"2021-09-13T20:44:48.0992701-03:00\",\"temperatureC\":3,\"temperatureF\":37,\"summary\":\"Freezing\"}]",
    "headers" : {
      "Date" : "Wed, 08 Sep 2021 23:44:47 GMT",
      "Content-Type" : "application/json; charset=utf-8",
      "Server" : "Kestrel"
    }
  },
  "uuid" : "ef53ea56-f118-4b3a-8c69-a9484851d99a",
  "persistent" : true,
  "insertionIndex" : 1
}

POST Sample

{
  "id" : "365dd908-dc67-4f27-9e41-15d908206d81",
  "name" : "weatherforecast_register-city",
  "request" : {
    "url" : "/WeatherForecast/register-city",
    "method" : "POST",
    "bodyPatterns" : [ {
      "equalToJson" : "{ \"cityName\": \"São Paulo\", \"cityCode\": 5001 }",
      "ignoreArrayOrder" : true,
      "ignoreExtraElements" : true
    } ]
  },
  "response" : {
    "status" : 200,
    "headers" : {
      "Date" : "Wed, 08 Sep 2021 23:48:33 GMT",
      "Server" : "Kestrel"
    }
  },
  "uuid" : "365dd908-dc67-4f27-9e41-15d908206d81",
  "persistent" : true,
  "insertionIndex" : 4
}
@rodrigoramos commented on GitHub (Sep 9, 2021): Hi @StefH! Thanks for your answer. IMO, I'd preferred an "import/read" capability. I cannot share exactly the models that I'm working on (company's policy) but I can share some samples that I created in order to understand the Playback/Recording functionality. GET Sample ``` { "id" : "ef53ea56-f118-4b3a-8c69-a9484851d99a", "name" : "weatherforecast", "request" : { "url" : "/WeatherForecast", "method" : "GET" }, "response" : { "status" : 200, "body" : "[{\"date\":\"2021-09-09T20:44:48.0992639-03:00\",\"temperatureC\":51,\"temperatureF\":123,\"summary\":\"Hot\"},{\"date\":\"2021-09-10T20:44:48.0992692-03:00\",\"temperatureC\":34,\"temperatureF\":93,\"summary\":\"Mild\"},{\"date\":\"2021-09-11T20:44:48.0992696-03:00\",\"temperatureC\":43,\"temperatureF\":109,\"summary\":\"Sweltering\"},{\"date\":\"2021-09-12T20:44:48.0992698-03:00\",\"temperatureC\":46,\"temperatureF\":114,\"summary\":\"Cool\"},{\"date\":\"2021-09-13T20:44:48.0992701-03:00\",\"temperatureC\":3,\"temperatureF\":37,\"summary\":\"Freezing\"}]", "headers" : { "Date" : "Wed, 08 Sep 2021 23:44:47 GMT", "Content-Type" : "application/json; charset=utf-8", "Server" : "Kestrel" } }, "uuid" : "ef53ea56-f118-4b3a-8c69-a9484851d99a", "persistent" : true, "insertionIndex" : 1 } ``` POST Sample ``` { "id" : "365dd908-dc67-4f27-9e41-15d908206d81", "name" : "weatherforecast_register-city", "request" : { "url" : "/WeatherForecast/register-city", "method" : "POST", "bodyPatterns" : [ { "equalToJson" : "{ \"cityName\": \"São Paulo\", \"cityCode\": 5001 }", "ignoreArrayOrder" : true, "ignoreExtraElements" : true } ] }, "response" : { "status" : 200, "headers" : { "Date" : "Wed, 08 Sep 2021 23:48:33 GMT", "Server" : "Kestrel" } }, "uuid" : "365dd908-dc67-4f27-9e41-15d908206d81", "persistent" : true, "insertionIndex" : 4 } ```
Author
Owner

@StefH commented on GitHub (Sep 12, 2021):

@rodrigoramos
Something like ImportWireMockOrg(string path) as public method on WireMockServer?

@StefH commented on GitHub (Sep 12, 2021): @rodrigoramos Something like `ImportWireMockOrg(string path)` as public method on WireMockServer?
Author
Owner

@StefH commented on GitHub (Sep 12, 2021):

@rodrigoramos & @Ppiwow
I've create a preview version WireMock.1.4.21-preview-04-ci-15384 which has an extra method to import 1 json file.

https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions

In the next days, I'll add more logic and unittests. And if you encounter issues, please write tehse here.

@StefH commented on GitHub (Sep 12, 2021): @rodrigoramos & @Ppiwow I've create a preview version `WireMock.1.4.21-preview-04-ci-15384` which has an extra method to import 1 json file. https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions In the next days, I'll add more logic and unittests. And if you encounter issues, please write tehse here.
Author
Owner

@StefH commented on GitHub (Sep 16, 2021):

https://github.com/WireMock-Net/WireMock.Net/pull/631

@StefH commented on GitHub (Sep 16, 2021): https://github.com/WireMock-Net/WireMock.Net/pull/631
Author
Owner

@StefH commented on GitHub (Sep 16, 2021):

Some compatibility has been added.

You can now post Create a new single WireMock.org stub mapping or an array from WireMock.org mappings to /__admin/mappings/wiremock.org

Please try this functionality and create a new issue in case you miss something.

A new version will be released shortly.

@StefH commented on GitHub (Sep 16, 2021): Some compatibility has been added. You can now post Create a new single WireMock.org stub mapping or an array from WireMock.org mappings to `/__admin/mappings/wiremock.org` Please try this functionality and create a new issue in case you miss something. A new version will be released shortly.
Author
Owner

@rodrigoramos commented on GitHub (Sep 16, 2021):

Thank you so much.

Em qui., 16 de set. de 2021 09:37, Stef Heyenrath @.***>
escreveu:

Some compatibility has been added.

You can now post Create a new single WireMock.org stub mapping or an array
from WireMock.org mappings to /__admin/mappings/wiremock.org

Please try this functionality and create a new issue in case you miss
something.

A new version will be released shortly.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/WireMock-Net/WireMock.Net/issues/491#issuecomment-920863274,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAL64CMXKTC4YACXHAYY7KDUCHQHBANCNFSM4PCFIUQQ
.
Triage notifications on the go with GitHub Mobile for iOS
https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675
or Android
https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

@rodrigoramos commented on GitHub (Sep 16, 2021): Thank you so much. Em qui., 16 de set. de 2021 09:37, Stef Heyenrath ***@***.***> escreveu: > Some compatibility has been added. > > You can now post Create a new single WireMock.org stub mapping or an array > from WireMock.org mappings to /__admin/mappings/wiremock.org > > Please try this functionality and create a new issue in case you miss > something. > > A new version will be released shortly. > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > <https://github.com/WireMock-Net/WireMock.Net/issues/491#issuecomment-920863274>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AAL64CMXKTC4YACXHAYY7KDUCHQHBANCNFSM4PCFIUQQ> > . > Triage notifications on the go with GitHub Mobile for iOS > <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> > or Android > <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>. > >
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#283