Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def json(self, spec_version):
"""Convert the Response to a JSON Pact."""
response = {"status": self.status}
if self.body is not None:
response["body"] = get_generated_values(self.body)
if self.headers:
response["headers"] = get_generated_values(self.headers)
if spec_version == "2.0.0":
matchingRules = self.generate_v2_matchingRules()
elif spec_version == "3.0.0":
matchingRules = self.generate_v3_matchingRules()
else:
raise ValueError(f"Invalid Pact specification version={spec_version}")
if matchingRules:
response["matchingRules"] = matchingRules
return response
def json(self, spec_version):
"""Convert the Request to a JSON Pact."""
request = {"method": self.method, "path": get_generated_values(self.path)}
if self.headers:
request["headers"] = get_generated_values(self.headers)
if self.body is not None:
request["body"] = get_generated_values(self.body)
if self.query:
request["query"] = get_generated_values(self.query)
if spec_version == "2.0.0":
matchingRules = self.generate_v2_matchingRules()
elif spec_version == "3.0.0":
matchingRules = self.generate_v3_matchingRules()
else:
raise ValueError(f"Invalid Pact specification version={spec_version}")
def json(self, spec_version):
"""Convert the Request to a JSON Pact."""
request = {"method": self.method, "path": get_generated_values(self.path)}
if self.headers:
request["headers"] = get_generated_values(self.headers)
if self.body is not None:
request["body"] = get_generated_values(self.body)
if self.query:
request["query"] = get_generated_values(self.query)
if spec_version == "2.0.0":
matchingRules = self.generate_v2_matchingRules()
elif spec_version == "3.0.0":
matchingRules = self.generate_v3_matchingRules()
else:
raise ValueError(f"Invalid Pact specification version={spec_version}")
if matchingRules:
request["matchingRules"] = matchingRules
def json(self, spec_version):
"""Convert the Response to a JSON Pact."""
response = {"status": self.status}
if self.body is not None:
response["body"] = get_generated_values(self.body)
if self.headers:
response["headers"] = get_generated_values(self.headers)
if spec_version == "2.0.0":
matchingRules = self.generate_v2_matchingRules()
elif spec_version == "3.0.0":
matchingRules = self.generate_v3_matchingRules()
else:
raise ValueError(f"Invalid Pact specification version={spec_version}")
if matchingRules:
response["matchingRules"] = matchingRules
return response
def json(self, spec_version):
"""Convert the Request to a JSON Pact."""
request = {"method": self.method, "path": get_generated_values(self.path)}
if self.headers:
request["headers"] = get_generated_values(self.headers)
if self.body is not None:
request["body"] = get_generated_values(self.body)
if self.query:
request["query"] = get_generated_values(self.query)
if spec_version == "2.0.0":
matchingRules = self.generate_v2_matchingRules()
elif spec_version == "3.0.0":
matchingRules = self.generate_v3_matchingRules()
else:
raise ValueError(f"Invalid Pact specification version={spec_version}")
if matchingRules:
request["matchingRules"] = matchingRules
return request
def json(self, spec_version):
"""Convert the Request to a JSON Pact."""
request = {"method": self.method, "path": get_generated_values(self.path)}
if self.headers:
request["headers"] = get_generated_values(self.headers)
if self.body is not None:
request["body"] = get_generated_values(self.body)
if self.query:
request["query"] = get_generated_values(self.query)
if spec_version == "2.0.0":
matchingRules = self.generate_v2_matchingRules()
elif spec_version == "3.0.0":
matchingRules = self.generate_v3_matchingRules()
else:
raise ValueError(f"Invalid Pact specification version={spec_version}")
if matchingRules:
request["matchingRules"] = matchingRules
return request