spring 云合同消息传递 - 如何定义属性并使用正则表达式断言

spring cloud contract messaging - how to define an attribute and assert with a regex

鉴于:

与 Spring 云合同消息传递的定义合同。

https://github.com/nusmanov/producer/blob/master/src/test/resources/contracts/user-presence.yaml

问题:

制作人https://github.com/nusmanov/producer

消费者https://github.com/nusmanov/consumer

是的,你可以。请阅读此处 https://docs.spring.io/spring-cloud-contract/docs/current/reference/html/project-features.html#contract-dsl-dynamic-properties . Example of a messaging contract with matchers can be found here https://github.com/spring-cloud/spring-cloud-contract/blob/e91b91efba60c52c3e8a6e65171a9f6dd18cb276/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/messaging/integration/StubRunnerIntegrationMessageSelectorSpec.groovy#L198-L220 的文档。为了您的方便,我将其粘贴

Contract.make {
    input {
        messageFrom "foo"
        messageHeaders {
            header("foo", $(anyUuid()))
        }
        messageBody(foo: 123)
    }
}