spring-cloud / spring-cloud-contract

Support for Consumer Driven Contracts in Spring
https://cloud.spring.io/spring-cloud-contract
Apache License 2.0
717 stars 439 forks source link

Spring cloud contracts issue for snippet of body #2087

Open reddykmr opened 8 months ago

reddykmr commented 8 months ago

Hi @Everyone

I am facing issue to add matchers for below body of content , can you please suggest how to write matchers for below context the form of YAML format

request:
  method: POST
  urlPath: /v1/clients/hello
  queryParameters:
      clientType: 123
  headers:
    Content-Type: application/json

  body:
    customer:
    - address1:
        name: "test1"
        village: "test1"
      address2:
        name: "test2"
        village: "test3"

much appreciate for solution

reddykmr commented 8 months ago

can you pls check let me know actually this blocker for us

marcingrzejszczak commented 8 months ago

I don't know what you're trying to match. You have examples of matchers in the docs https://docs.spring.io/spring-cloud-contract/docs/current/reference/html/project-features.html#contract-dsl

reddykmr commented 8 months ago

Hi @marcingrzejszczak thanks for response, i went through above documentation here approach is different i want to bring the dynamic behavior for below block of part by using the matchers , can you help how to bring dynamic behavior for below

body:
    customer:
    - address1:
        name: "test1"
        village: "test1"
      address2:
        name: "test2"
        village: "test3"
marcingrzejszczak commented 8 months ago

Please read this section of the documentation.

reddykmr commented 8 months ago

thanks for it I went through that there its added regular expression for value , we need make allow the dynamic approach for address1 element i have followed below approach for address1 by adding regular expression but its not working can you you pls help on it how we can bring dynamic behavior for address1 since we need to add dynamically Note: address1 : ([a-zA-Z0-9]*) customer: