在 JSON 响应中引用正则表达式字符串

Reference regex string In JSON response

如何在 JSON 响应中引用正则表达式字符串

url value(consumer(regex('/connectors/(.*?)/status')))

所以如果我请求 '/connectors/foo/status' 我会得到 { "name": "foo" }

请阅读文档 - https://docs.spring.io/spring-cloud-contract/docs/current/reference/html/project-features.html#contract-dsl-referencing-request-from-response

你需要做

response {
  body(name: fromRequest().path(1))
}