Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring cloud contracts issue for snippet of body #2087

Open
reddykmr opened this issue Jan 23, 2024 · 5 comments
Open

Spring cloud contracts issue for snippet of body #2087

reddykmr opened this issue Jan 23, 2024 · 5 comments

Comments

@reddykmr
Copy link

reddykmr commented Jan 23, 2024

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
Copy link
Author

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

@marcingrzejszczak
Copy link
Contributor

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
Copy link
Author

reddykmr commented Jan 23, 2024

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
Copy link
Contributor

Please read this section of the documentation.

@reddykmr
Copy link
Author

reddykmr commented Jan 23, 2024

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:
- address1:
houseNo: "123"
matchers:
body:
- path: $.['customer'][
].['([a-zA-Z0-9])']['houseNo']
type: by_regex
value: ^([a-zA-Z0-9-_.]
)$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants