【发布时间】:2018-10-26 15:15:54
【问题描述】:
在spring cloud合约(v1.2.5)中使用这个合约:
Contract.make {
description "update sthg"
request {
method PUT()
url value($(consumer('/path/to/sthg'),
producer(execute('somePutPathPath(0,\"xxx\")'))))
body(producer(
file('files/givens/my-body.json')
))
}
response {
status 200
headers {
contentType(applicationJson())
}
body(fromRequest().body())
}
}
生成测试时出现错误
org.springframework.cloud:spring-cloud-contract-maven-plugin:1.2.5.RELEASE:generateTests failed:net.minidev.json.parser.ParseException: Unexpected character ({) at position 1. -> [Help 1]
但如果我使用,一切都很好:body(someProp: fromRequest().body())
Contract.make {
description "update sthg"
request {
method PUT()
url value($(consumer('/path/to/sthg'),
producer(execute('somePutPathPath(0,\"xxx\")'))))
body(producer(
file('files/givens/my-body.json')
))
}
response {
status 200
headers {
contentType(applicationJson())
}
body(someProp: fromRequest().body())
}
}
如何将正文响应设置为请求正文。
【问题讨论】:
标签: spring-cloud spring-cloud-contract