springgroovyspring-cloud-contract

Spring Cloud Contract Variable inside URL Path


My URL consists of variable inside the URL path as shown in the below request. I am not able to call this this request. Any idea if I can use regex?

request {
   method 'GET'
   url ('/accounts/groups/{Id}/locations) {
      queryParameters {
         parameter('Id', "568b444ae73eb5883d4a")
      }
   }
}

Solution

  • You don't need query parameters as your id is in the URL. What you need is an alphanumeric regex like so: url value(consumer(regex('/accounts/groups/[a-zA-Z0-9]+/locations')))

    More about Spring Cloud Contract regex here.