Allows passing of regex type (#832)

without this change if one does $(regex("[0-9]")) we have no knowledge of whether the result should be text or a number. What we do ATM is we always generate a String
with this change once can pass the type of regular expression and we will generate the concrete value of that given type

fixes gh-768
This commit is contained in:
Marcin Grzejszczak
2018-12-28 16:29:32 +01:00
committed by GitHub
parent 58bf533462
commit 56fbc11f62
40 changed files with 989 additions and 263 deletions

View File

@@ -801,7 +801,7 @@ following matching possibilities:
** `byEquality()`: The value taken from the consumer's request via the provided JSON Path must be
equal to the value provided in the contract.
** `byRegex(...)`: The value taken from the consumer's request via the provided JSON Path must
match the regex.
match the regex. You can also pass the type of the expected matched value (e.g. `asString()`, `asLong()` etc.)
** `byDate()`: The value taken from the consumer's request via the provided JSON Path must
match the regex for an ISO Date value.
** `byTimestamp()`: The value taken from the consumer's request via the provided JSON Path must
@@ -848,6 +848,7 @@ For YAML the structure of a matcher looks like this
- path: $.foo
type: by_regex
value: bar
regexType: as_string
----
Or if you want to use one of the predefined regular expressions
@@ -882,6 +883,16 @@ Below you can find the allowed list of `type`s.
** `by_command`
** `by_null`
You can also define which type the regular expression corresponds to via the `regexType` field. Below you can find the allowed list of regular expression types:
* as_integer
* as_double
* as_float,
* as_long
* as_short
* as_boolean
* as_string
Consider the following example:
.Groovy DSL