From 62e0ab2e5ad7f4dbbb3821cd4b56c4bc4a36935b Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Fri, 15 Oct 2021 17:01:22 +1100 Subject: [PATCH] chore: parse yaml contracts for pf --- lib/pact_broker/api/resources/publish_contracts.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/pact_broker/api/resources/publish_contracts.rb b/lib/pact_broker/api/resources/publish_contracts.rb index 2cf2ee1f3..923aece45 100644 --- a/lib/pact_broker/api/resources/publish_contracts.rb +++ b/lib/pact_broker/api/resources/publish_contracts.rb @@ -74,7 +74,11 @@ def schema def decode_and_parse_content(contract) contract["decodedContent"] = Base64.strict_decode64(contract["content"]) rescue nil if contract["decodedContent"] - contract["decodedParsedContent"] = PactBroker::Pacts::Parse.call(contract["decodedContent"]) rescue nil + if contract["contentType"]&.include?("json") + contract["decodedParsedContent"] = PactBroker::Pacts::Parse.call(contract["decodedContent"]) rescue nil + elsif contract["contentType"]&.include?("yml") + contract["decodedParsedContent"] = YAML.safe_load(contract["decodedContent"], [Time, Date, DateTime]) rescue nil + end end end