hey, I'm making a custom tool to convert wiremock ...
# pactflow
m
hey, I'm making a custom tool to convert wiremock json to pact contracts. When the generated contract is uploaded, I have stumbled onto an error message in the contract comparison tab:
requestQuery[queryName].join is not a function
. The consumer contract tab is showing the expected requests/responses with matchers, there is also an existing open api spec to compare against. any help much appreciated
y
Is it a valid contract? Can you provide a sample? There is a Pact specification schema that has been developed, which you can use to validate against https://github.com/pactflow/pact-schemas
m
There are two existing wiremock Pact serialisers: • https://docs.pactflow.io/docs/bi-directional-contract-testing/tools/wiremock/ • https://docs.pactflow.io/docs/bi-directional-contract-testing/tools/wiremock-net I’m assuming you’re not using the Java/.NET versions of wiremock?
or is it more that you want to convert the wiremock JSON (rather than from execution)?
m
hi Matt, thanks for the responses. Yes we have multiple languages used in the company so can't rely on Java (don't use .NET at all). Also the Java implementation is quite outdated and does not allow for easy support for multiple providers per consumer, without spinning up multiple wiremock servers. We are also using the output from wiremock post execution as you mentioned, where we'll have all the data / metadata present that we need to generate multiple contract files. I have used pact v4 to create those contracts. Here's the query part of the request:
Copy code
"query": {
          "amount": "100",
          "buy_currency": "USD",
          "sell_currency": "GBP",
          "fixed_side": "sell",
          "delivery_date": "2023-11-29"
        },
        "body": {
          "content": "",
          "contentType": "application/json",
          "encoded": false,
          "contentTypeHint": "TEXT"
        },
        "matchingRules": {
          "query": {
            "amount": {
              "matchers": [
                {
                  "match": "type"
                }
              ]
            },
            "buy_currency": {
              "matchers": [
                {
                  "match": "type"
                }
              ]
            },
            "sell_currency": {
              "matchers": [
                {
                  "match": "type"
                }
              ]
            },
            "fixed_side": {
              "matchers": [
                {
                  "match": "type"
                }
              ]
            },
            "delivery_date": {
              "matchers": [
                {
                  "match": "type"
                }
              ]
            }
          },
          "body": {
            "$": {
              "combine": "AND",
              "matchers": [
                {
                  "match": "type"
                }
              ]
            }
          }
thankyou 1
using a schema validator, the full file validates against v4 without errors thinking
m
Interesting use case. Any chance you could share the whole file? I can then try to determine the problem
m
yep will send it over
thankyou 1