Skip to content

Commit 476ff59

Browse files
committed
fix: support application/vnd.pactbrokerextended.v1+json for latest pact resource
1 parent 31fb8aa commit 476ff59

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

lib/pact_broker/api/resources/latest_pact.rb

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
require 'pact_broker/api/resources/base_resource'
22
require 'pact_broker/configuration'
3+
require 'pact_broker/api/decorators/extended_pact_decorator'
34

45
module PactBroker
56
module Api
67
module Resources
7-
88
class LatestPact < BaseResource
9-
109
def content_types_provided
11-
[ ["application/hal+json", :to_json],
10+
[
11+
["application/hal+json", :to_json],
1212
["application/json", :to_json],
13-
["text/html", :to_html]]
13+
["text/html", :to_html],
14+
["application/vnd.pactbrokerextended.v1+json", :to_extended_json]
15+
]
1416
end
1517

1618
def allowed_methods
@@ -26,6 +28,10 @@ def to_json
2628
PactBroker::Api::Decorators::PactDecorator.new(pact).to_json(user_options: { base_url: base_url })
2729
end
2830

31+
def to_extended_json
32+
PactBroker::Api::Decorators::ExtendedPactDecorator.new(pact).to_json(user_options: decorator_context(metadata: identifier_from_path[:metadata]))
33+
end
34+
2935
def to_html
3036
PactBroker.configuration.html_pact_renderer.call(
3137
pact, {

lib/pact_broker/api/resources/pact.rb

+5-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ class Pact < BaseResource
2525
include WebhookExecutionMethods
2626

2727
def content_types_provided
28-
[["application/hal+json", :to_json],
29-
["application/json", :to_json],
30-
["text/html", :to_html],
31-
["application/vnd.pactbrokerextended.v1+json", :to_extended_json]
28+
[
29+
["application/hal+json", :to_json],
30+
["application/json", :to_json],
31+
["text/html", :to_html],
32+
["application/vnd.pactbrokerextended.v1+json", :to_extended_json]
3233
]
3334
end
3435

0 commit comments

Comments
 (0)