pact-foundation / pact-jvm

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://docs.pact.io
Apache License 2.0
1.09k stars 480 forks source link

Is `"min": 0` needed in matchers generated by Consumer PactDSL? (GroovyDSL doesn't use it) #1289

Closed tlinkowski closed 3 years ago

tlinkowski commented 3 years ago

Current status

Right now:

Example:

Consequences

Apart from the obvious (and unintuitive) discrepancy between PactDSL and GroovyDSL, the main drawback is that Pact Broker does not render the content of such eachLikes when it renders them.

That is, instead of:

"values": [
  "example"
]

Pact broker renders:

"values": [
]

which makes the preview in Pact Broker very much useless 😞

Question

Can the following occurrences of matchMin(0) below be replaced with TypeMatcher.INSTANCE?

  1. https://github.com/pact-foundation/pact-jvm/blob/57a8541e08cbecb2c324010b8a8423fd9d2aeb1b/consumer/src/main/java/au/com/dius/pact/consumer/dsl/PactDslJsonBody.java#L740
  2. https://github.com/pact-foundation/pact-jvm/blob/57a8541e08cbecb2c324010b8a8423fd9d2aeb1b/consumer/src/main/java/au/com/dius/pact/consumer/dsl/PactDslJsonBody.java#L769
  3. https://github.com/pact-foundation/pact-jvm/blob/57a8541e08cbecb2c324010b8a8423fd9d2aeb1b/consumer/src/main/java/au/com/dius/pact/consumer/dsl/PactDslJsonBody.java#L796
  4. https://github.com/pact-foundation/pact-jvm/blob/57a8541e08cbecb2c324010b8a8423fd9d2aeb1b/consumer/src/main/java/au/com/dius/pact/consumer/dsl/PactDslJsonBody.java#L1082
  5. https://github.com/pact-foundation/pact-jvm/blob/57a8541e08cbecb2c324010b8a8423fd9d2aeb1b/consumer/src/main/java/au/com/dius/pact/consumer/dsl/PactDslJsonBody.java#L1156
  6. https://github.com/pact-foundation/pact-jvm/blob/57a8541e08cbecb2c324010b8a8423fd9d2aeb1b/consumer/src/main/java/au/com/dius/pact/consumer/dsl/PactDslJsonArray.java#L129
  7. https://github.com/pact-foundation/pact-jvm/blob/57a8541e08cbecb2c324010b8a8423fd9d2aeb1b/consumer/src/main/java/au/com/dius/pact/consumer/dsl/PactDslJsonArray.java#L148
  8. https://github.com/pact-foundation/pact-jvm/blob/57a8541e08cbecb2c324010b8a8423fd9d2aeb1b/consumer/src/main/java/au/com/dius/pact/consumer/dsl/PactDslJsonArray.java#L736
  9. https://github.com/pact-foundation/pact-jvm/blob/57a8541e08cbecb2c324010b8a8423fd9d2aeb1b/consumer/src/main/java/au/com/dius/pact/consumer/dsl/PactDslJsonArray.java#L754
  10. https://github.com/pact-foundation/pact-jvm/blob/57a8541e08cbecb2c324010b8a8423fd9d2aeb1b/consumer/src/main/java/au/com/dius/pact/consumer/dsl/PactDslJsonArray.java#L955
  11. https://github.com/pact-foundation/pact-jvm/blob/57a8541e08cbecb2c324010b8a8423fd9d2aeb1b/consumer/src/main/java/au/com/dius/pact/consumer/dsl/PactDslJsonArray.java#L1034

Would you accept a PR with such a change?

uglyog commented 3 years ago

PRs are always welcome, but in this case it was a small change so I just did it.

uglyog commented 3 years ago

4.1.17 has been released