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