spring-cloud-contract
spring-cloud-contract copied to clipboard
Object properties can't be referenced from the response
On the groovy contract, the reference feature doesn't work when a complex field (object) is referenced from the response. In other words, when the field from the request body is an object, the generated test doesn’t compile as it generates a json string with no double quotes.
If baz is a json object on the request's body, then this command is supposed to include it on the response:
baz: fromRequest().body('$.baz’)
The generated test source code looks like this:
assertThatJson(parsedJson).field("['baz']").isEqualTo({myfieldOne=field});
Finally baz is defined like this:
body( baz : [myfieldOne: "field"] )
@marcingrzejszczak
@diegobe, do you think following my failure is same with current issue?
Failed to execute goal org.springframework.cloud:spring-cloud-contract-maven-plugin:1.1.1.RELEASE:generateTests (default-generateTests) on project scheduler-server: Execution default-generateTests of goal org.springframework.cloud:spring-cloud-contract-maven-plugin:1.1.1.RELEASE:generateTests failed: inline@2c8f1563:41:87: com.jayway.jsonpath.PathNotFoundException: Expected to find an object with property ['uri'] in path $ but found 'java.lang.String'. This is not a json object according to the JsonProvider: 'com.jayway.jsonpath.spi.json.JsonSmartJsonProvider'.
If so, do you know when the issue will be fixed? Thanks a lot.