I have a spring cloud contract(written in groovy dsl) which takes a object(Let's say Employee with 5 fields) as a request and updated object(Employee) back as a response.
Here scenario is all of 5 fields in Employee object is not mandatory. We can have any fields out of 5 fields in the request.
Is there a way to make those fields are optional in spring cloud contract?
Note: email: $(consumer(optional(regex(email()))), producer('abc@abc.com'))
does not work because it just makes value optional not field.
Any help will be appreciated. Thanks!
No you can't. You can make a value of a field optional. If a field is optional then create two contracts. One with the field and one without it.