Skip to content

regex and double quotes #169

@jfgosselin

Description

@jfgosselin
package contracts

org.springframework.cloud.contract.spec.Contract.make {
  request {
    method 'POST'
    url '/foo'
    body(
    	xyz: 'abc'
    )
    headers { header('Content-Type', 'application/json;charset=UTF-8') }
  }
  response {
    status 200	
    body( 
		 bar: $(consumer(regex('some value \u0022with quote\u0022|bar')))
	)    
	headers { header('Content-Type': 'application/json;charset=UTF-8') }  
 }
}

I'm trying the above regex but I get the double escaping in my ContractVerifierTest.java ... same with regex('some value \"with quote\"|bar')

DocumentContext parsedJson = JsonPath.parse(response.getBody().asString());
assertThatJson(parsedJson).field("bar").matches("some value \\"with quote\\"|bar");

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions