File tree Expand file tree Collapse file tree 3 files changed +28
-6
lines changed
lib/rspec_api_documentation Expand file tree Collapse file tree 3 files changed +28
-6
lines changed Original file line number Diff line number Diff line change @@ -25,15 +25,25 @@ def request_headers
2525 end
2626
2727 def response_headers
28- last_response . headers
28+ if last_response . respond_to? ( :headers )
29+ last_response . headers
30+ elsif last_response . respond_to? ( :env ) && last_response . env . respond_to? ( :response_headers )
31+ last_response . env . response_headers
32+ else
33+ { }
34+ end
2935 end
3036
3137 def query_string
3238 last_request . env [ "QUERY_STRING" ]
3339 end
3440
3541 def status
36- last_response . status
42+ if last_response . respond_to? ( :status )
43+ last_response . status
44+ else
45+ last_response . env . status if last_response . respond_to? ( :env )
46+ end
3747 end
3848
3949 def response_body
@@ -45,7 +55,13 @@ def request_content_type
4555 end
4656
4757 def response_content_type
48- last_response . content_type
58+ if last_response . respond_to? ( :content_type )
59+ last_response . content_type
60+ elsif last_response . respond_to? ( :headers )
61+ last_response . headers [ 'Content-Type' ] || last_response . headers [ 'content-type' ]
62+ else
63+ nil
64+ end
4965 end
5066
5167 protected
@@ -71,7 +87,13 @@ def access_token
7187 @access_token ||= begin
7288 app = ProxyApp . new ( self , context . app )
7389 stub_request ( :any , %r{http://example\. com} ) . to_rack ( app )
74- Rack ::OAuth2 ::Client . new ( options . merge ( :host => "example.com" , :scheme => "http" ) ) . access_token!
90+
91+ # Create a Bearer access token as MAC is no longer supported
92+ access_token = Rack ::OAuth2 ::AccessToken ::Bearer . new (
93+ :access_token => options [ :identifier ] || "1"
94+ )
95+
96+ access_token
7597 end
7698 end
7799 end
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ module Writers
33 module Formatter
44
55 def self . to_json ( object )
6- JSON . pretty_generate ( object . as_json )
6+ JSON . pretty_generate ( object . as_json ) + " \n "
77 end
88
99 end
Original file line number Diff line number Diff line change @@ -119,7 +119,7 @@ def process_responses(responses, example)
119119 if /\A (?<response_content_type>[^;]+)/ =~ request [ :response_content_type ]
120120 response . safe_assign_setting ( :examples , OpenApi ::Example . new )
121121 response_body = JSON . parse ( request [ :response_body ] ) rescue nil
122- response . examples . add_setting response_content_type , :value => response_body
122+ response . examples . add_setting response_content_type , :value => response_body if response_body
123123 end
124124 responses . add_setting "#{ request [ :response_status ] } " , :value => response
125125 end
You can’t perform that action at this time.
0 commit comments