diff --git a/lib/pact_broker/api/resources/latest_pact.rb b/lib/pact_broker/api/resources/latest_pact.rb index d1a3aa5e6..000c78a43 100644 --- a/lib/pact_broker/api/resources/latest_pact.rb +++ b/lib/pact_broker/api/resources/latest_pact.rb @@ -1,16 +1,18 @@ require 'pact_broker/api/resources/base_resource' require 'pact_broker/configuration' +require 'pact_broker/api/decorators/extended_pact_decorator' module PactBroker module Api module Resources - class LatestPact < BaseResource - def content_types_provided - [ ["application/hal+json", :to_json], + [ + ["application/hal+json", :to_json], ["application/json", :to_json], - ["text/html", :to_html]] + ["text/html", :to_html], + ["application/vnd.pactbrokerextended.v1+json", :to_extended_json] + ] end def allowed_methods @@ -26,6 +28,10 @@ def to_json PactBroker::Api::Decorators::PactDecorator.new(pact).to_json(user_options: { base_url: base_url }) end + def to_extended_json + PactBroker::Api::Decorators::ExtendedPactDecorator.new(pact).to_json(user_options: decorator_context(metadata: identifier_from_path[:metadata])) + end + def to_html PactBroker.configuration.html_pact_renderer.call( pact, { diff --git a/lib/pact_broker/api/resources/pact.rb b/lib/pact_broker/api/resources/pact.rb index 985445412..cf971d41c 100644 --- a/lib/pact_broker/api/resources/pact.rb +++ b/lib/pact_broker/api/resources/pact.rb @@ -25,10 +25,11 @@ class Pact < BaseResource include WebhookExecutionMethods def content_types_provided - [["application/hal+json", :to_json], - ["application/json", :to_json], - ["text/html", :to_html], - ["application/vnd.pactbrokerextended.v1+json", :to_extended_json] + [ + ["application/hal+json", :to_json], + ["application/json", :to_json], + ["text/html", :to_html], + ["application/vnd.pactbrokerextended.v1+json", :to_extended_json] ] end