简体   繁体   中英

can we make spring cloud contract request/response attribute optional?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM