-
Notifications
You must be signed in to change notification settings - Fork 440
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
bodyMatchers' validations are not overwriting equality validation in request body #2115
Comments
That's a bug. WHen you're using a jsonpath matcher then it should not do the equality check |
Ah, you have a bug in your contract. rg.springframework.cloud.contract.spec.Contract.
make {
request {
method('PUT')
url("/fetch-recommendations")
headers {
header(contentType(), applicationJson())
}
body(
userId: "e9fbebcf-abb4-4097-831a-f3f279714d8",
preferedGenres: [
"Platformer", "Stealth", "Adventrure"
]
)
bodyMatchers {
jsonPath('$.userId', byRegex(uuid()))
}
}
response {
status OK()
}
} You have an extra |
I removed the "asString()" instruction and is still happening I believe you didn't replicated it accurately, this is happening when the body is coming from a separated json file. I left pictures of the json file describing the request body and the contract referencing it through file(String). request.json <-- here's the json representing the request body @marcingrzejszczak could you please give it another try with the right scenario? |
Sure, I'll check it out tomorrow |
Hi! Any news for this? |
I'm using the body matchers section of the contract to validate the userId field which must be an UUID. The problem arises when I build the project and generate the stub which has a equality validation and a UUID regex validation at the same time. The expected behavior is to have only the UUID regex validation.
This breakes the integration test in the consumer side because the mock server is basically trying to match like:
userId.equals("specificUserID") && isUUID()
and I just need:
isUUID()
You might say: "well the user can simply pass the specific UUID defined in the stub" but that would take freedom and independence to the consumer which goes against the intent of contract testing.
PD: I'm using spring-cloud-starter-contract-verifier version 4.1.0
The text was updated successfully, but these errors were encountered: