Skip to content

Commit

Permalink
fix: support application/vnd.pactbrokerextended.v1+json for latest pa…
Browse files Browse the repository at this point in the history
…ct resource
  • Loading branch information
bethesque committed Sep 30, 2019
1 parent 31fb8aa commit 476ff59
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
14 changes: 10 additions & 4 deletions lib/pact_broker/api/resources/latest_pact.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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, {
Expand Down
9 changes: 5 additions & 4 deletions lib/pact_broker/api/resources/pact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 476ff59

Please sign in to comment.