Hi, I'm using Pact JVM to generate my consumer con...
# pact-jvm
s
Hi, I'm using Pact JVM to generate my consumer contracts to further upload them to Pactflow. I'm facing an issue with wildcards usage in matchQuery method. When I'm using
matchQuery("myQueryParam", ".*")
it's generating a value which is not supported by Pactflow. Example of generated value:
"\u095D"
. Do you think this should be fixed in Pact JVM or Pactflow should be able to handle values like this?
FYI: I already found a way to continue with a more precise regex. But still would be nice to fix the issue
u
If you don't provide an example value, it will generate a random one from the regex. Just provide an example as the third parameter
b
As an aside, the generated string for
.*
might be highlighting edge cases you hadn't thought about 🙂
s
@uglyog but in this case Pactflow should handle all kind of characters randomly generated by Pact
🤔 1
Currently if I have a Pact containing "\u095D" Pactflow will not accept it and fail with 500 error I think
b
I'm not so sure about that . . . query parameters don't actually support
.*
, because characters need to be encoded outside the acceptable list. I don't know if it's reasonable to expect
matchQuery
to encode things for you, or if that should be a distinct capability, or option to the method. 🤔
u
Better to use
[a-zA-Z0-9]+
s
@uglyog yes, that's similar to what I did. But if let's say query parameters are allowed to have other characters than alphanumeric, that can take much more time to define a regex.
Is it an option to have a method like
queryString
which will work like
stringType
in body? Let's say I'm interested only to say that there will be a query parameter with specific name and I'm not concerned what will be the format of it's value.
I tried using
query
method but getting
IndexOutOfBoundsException
. So I assume this method has different purpose. Could you please confirm?
u
Just give it any example value, it will use a matcher when required
👍 1
s
Thanks for good suggestion!