rspec_api_documentation 4.3.0 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rspec_api_documentation.rb +1 -0
- data/lib/rspec_api_documentation/assets/stylesheets/rspec_api_documentation/styles.css +1 -6
- data/lib/rspec_api_documentation/client_base.rb +14 -0
- data/lib/rspec_api_documentation/configuration.rb +12 -0
- data/lib/rspec_api_documentation/dsl.rb +5 -0
- data/lib/rspec_api_documentation/dsl/endpoint.rb +16 -7
- data/lib/rspec_api_documentation/dsl/resource.rb +12 -15
- data/lib/rspec_api_documentation/headers.rb +1 -0
- data/lib/rspec_api_documentation/http_test_client.rb +0 -15
- data/lib/rspec_api_documentation/rack_test_client.rb +0 -14
- data/lib/rspec_api_documentation/views/markup_example.rb +1 -1
- data/lib/rspec_api_documentation/writers/combined_text_writer.rb +1 -1
- data/lib/rspec_api_documentation/writers/json_writer.rb +1 -1
- data/templates/rspec_api_documentation/html_example.mustache +9 -5
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1f384a163dd016f784e49be257ea8c41b36c462
|
4
|
+
data.tar.gz: dd948cacf84ba686f5368bafdc39bf70dfa5fc2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0eeb83e3a3f341a0df20d1cd50826d34ba29dc45dde5ddfcc1b82d8be3c36936cbcaf093d7f6d2c96b5fb44af6f5954e8267069b172b6030904e418377245837
|
7
|
+
data.tar.gz: 84093be0b80f3550526e337e0038dfab66e857cd66e3629e29ca3568e1a87e486a54b29897f0ed7b37ef58f744e7b2eb53d4d5c99db5b8e5cd4d03f63fc0ad80
|
@@ -45,11 +45,6 @@ a{
|
|
45
45
|
font-weight: inherit;
|
46
46
|
}
|
47
47
|
|
48
|
-
p {
|
49
|
-
padding: 15px;
|
50
|
-
font-size: 130%;
|
51
|
-
}
|
52
|
-
|
53
48
|
h1, h2, h3, h4, h5, h6 {
|
54
49
|
font-weight: bold;
|
55
50
|
color: #404040;
|
@@ -99,4 +94,4 @@ table th, table td {
|
|
99
94
|
padding: 10px 10px 9px;
|
100
95
|
line-height: 18px;
|
101
96
|
text-align: left;
|
102
|
-
}
|
97
|
+
}
|
@@ -84,5 +84,19 @@ module RspecApiDocumentation
|
|
84
84
|
def headers(method, path, params, request_headers)
|
85
85
|
request_headers || {}
|
86
86
|
end
|
87
|
+
|
88
|
+
def clean_out_uploaded_data(params, request_body)
|
89
|
+
params.each do |_, value|
|
90
|
+
if value.is_a?(Hash)
|
91
|
+
if value.has_key?(:tempfile)
|
92
|
+
data = value[:tempfile].read
|
93
|
+
request_body = request_body.gsub(data, "[uploaded data]")
|
94
|
+
else
|
95
|
+
request_body = clean_out_uploaded_data(value,request_body)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
request_body
|
100
|
+
end
|
87
101
|
end
|
88
102
|
end
|
@@ -106,6 +106,18 @@ module RspecApiDocumentation
|
|
106
106
|
@client_method ||= :client
|
107
107
|
end
|
108
108
|
|
109
|
+
def disable_dsl_status!
|
110
|
+
RspecApiDocumentation::DSL::Endpoint.module_eval <<-RUBY
|
111
|
+
undef status
|
112
|
+
RUBY
|
113
|
+
end
|
114
|
+
|
115
|
+
def disable_dsl_method!
|
116
|
+
RspecApiDocumentation::DSL::Endpoint.module_eval <<-RUBY
|
117
|
+
undef method
|
118
|
+
RUBY
|
119
|
+
end
|
120
|
+
|
109
121
|
def settings
|
110
122
|
@settings ||= {}
|
111
123
|
end
|
@@ -35,3 +35,8 @@ RSpec.configuration.include RspecApiDocumentation::DSL::Resource, :api_doc_dsl =
|
|
35
35
|
RSpec.configuration.include RspecApiDocumentation::DSL::Endpoint, :api_doc_dsl => :endpoint
|
36
36
|
RSpec.configuration.include RspecApiDocumentation::DSL::Callback, :api_doc_dsl => :callback
|
37
37
|
RSpec.configuration.backtrace_exclusion_patterns << %r{lib/rspec_api_documentation/dsl/}
|
38
|
+
|
39
|
+
if defined? RSpec::Rails
|
40
|
+
RSpec::Rails::DIRECTORY_MAPPINGS[:acceptance] = %w[spec acceptance]
|
41
|
+
RSpec.configuration.infer_spec_type_from_file_location!
|
42
|
+
end
|
@@ -8,7 +8,7 @@ module RspecApiDocumentation::DSL
|
|
8
8
|
extend ActiveSupport::Concern
|
9
9
|
include Rack::Test::Utils
|
10
10
|
|
11
|
-
delegate :response_headers, :
|
11
|
+
delegate :response_headers, :response_status, :response_body, :to => :rspec_api_documentation_client
|
12
12
|
|
13
13
|
module ClassMethods
|
14
14
|
def example_request(description, params = {}, &block)
|
@@ -35,16 +35,16 @@ module RspecApiDocumentation::DSL
|
|
35
35
|
params_or_body = nil
|
36
36
|
path_or_query = path
|
37
37
|
|
38
|
-
if
|
38
|
+
if http_method == :get && !query_string.blank?
|
39
39
|
path_or_query += "?#{query_string}"
|
40
40
|
else
|
41
|
-
if respond_to?(:raw_post)
|
41
|
+
if respond_to?(:raw_post)
|
42
42
|
params_or_body = raw_post
|
43
43
|
else
|
44
44
|
formatter = RspecApiDocumentation.configuration.post_body_formatter
|
45
45
|
case formatter
|
46
46
|
when :json
|
47
|
-
params_or_body = params.to_json
|
47
|
+
params_or_body = params.empty? ? nil : params.to_json
|
48
48
|
when :xml
|
49
49
|
params_or_body = params.to_xml
|
50
50
|
when Proc
|
@@ -55,7 +55,7 @@ module RspecApiDocumentation::DSL
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
rspec_api_documentation_client.send(
|
58
|
+
rspec_api_documentation_client.send(http_method, path_or_query, params_or_body, headers)
|
59
59
|
end
|
60
60
|
|
61
61
|
def query_string
|
@@ -66,7 +66,7 @@ module RspecApiDocumentation::DSL
|
|
66
66
|
parameters = example.metadata.fetch(:parameters, {}).inject({}) do |hash, param|
|
67
67
|
set_param(hash, param)
|
68
68
|
end
|
69
|
-
parameters.
|
69
|
+
parameters.deep_merge!(extra_params)
|
70
70
|
parameters
|
71
71
|
end
|
72
72
|
|
@@ -87,10 +87,18 @@ module RspecApiDocumentation::DSL
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
def
|
90
|
+
def http_method
|
91
91
|
example.metadata[:method]
|
92
92
|
end
|
93
93
|
|
94
|
+
def method
|
95
|
+
http_method
|
96
|
+
end
|
97
|
+
|
98
|
+
def status
|
99
|
+
rspec_api_documentation_client.status
|
100
|
+
end
|
101
|
+
|
94
102
|
def in_path?(param)
|
95
103
|
path_params.include?(param)
|
96
104
|
end
|
@@ -128,6 +136,7 @@ module RspecApiDocumentation::DSL
|
|
128
136
|
def extra_params
|
129
137
|
return {} if @extra_params.nil?
|
130
138
|
@extra_params.inject({}) do |h, (k, v)|
|
139
|
+
v = v.is_a?(Hash) ? v.stringify_keys : v
|
131
140
|
h[k.to_s] = v
|
132
141
|
h
|
133
142
|
end
|
@@ -51,28 +51,25 @@ module RspecApiDocumentation::DSL
|
|
51
51
|
end
|
52
52
|
|
53
53
|
private
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
|
55
|
+
def safe_metadata(field, default)
|
56
|
+
metadata[field] ||= default
|
57
|
+
if superclass_metadata && metadata[field].equal?(superclass_metadata[field])
|
58
|
+
metadata[field] = Marshal.load(Marshal.dump(superclass_metadata[field]))
|
58
59
|
end
|
59
|
-
metadata[
|
60
|
+
metadata[field]
|
61
|
+
end
|
62
|
+
|
63
|
+
def parameters
|
64
|
+
safe_metadata(:parameters, [])
|
60
65
|
end
|
61
66
|
|
62
67
|
def response_fields
|
63
|
-
|
64
|
-
if superclass_metadata && metadata[:response_fields].equal?(superclass_metadata[:response_fields])
|
65
|
-
metadata[:response_fields] = Marshal.load(Marshal.dump(superclass_metadata[:response_fields]))
|
66
|
-
end
|
67
|
-
metadata[:response_fields]
|
68
|
+
safe_metadata(:response_fields, [])
|
68
69
|
end
|
69
70
|
|
70
71
|
def headers
|
71
|
-
|
72
|
-
if superclass_metadata && metadata[:headers].equal?(superclass_metadata[:headers])
|
73
|
-
metadata[:headers] = Marshal.load(Marshal.dump(superclass_metadata[:headers]))
|
74
|
-
end
|
75
|
-
metadata[:headers]
|
72
|
+
safe_metadata(:headers, {})
|
76
73
|
end
|
77
74
|
|
78
75
|
def parameter_keys
|
@@ -94,21 +94,6 @@ module RspecApiDocumentation
|
|
94
94
|
|
95
95
|
private
|
96
96
|
|
97
|
-
def clean_out_uploaded_data(params, request_body)
|
98
|
-
params.each do |_, value|
|
99
|
-
if value.is_a?(Hash)
|
100
|
-
if value.has_key?(:tempfile)
|
101
|
-
data = value[:tempfile].read
|
102
|
-
request_body = request_body.gsub(data, "[uploaded data]")
|
103
|
-
else
|
104
|
-
request_body = clean_out_uploaded_data(value,request_body)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
request_body
|
109
|
-
end
|
110
|
-
|
111
|
-
|
112
97
|
def http_test_session
|
113
98
|
::Faraday.new(:url => options[:host]) do |faraday|
|
114
99
|
faraday.request :url_encoded # form-encode POST params
|
@@ -53,20 +53,6 @@ module RspecApiDocumentation
|
|
53
53
|
|
54
54
|
private
|
55
55
|
|
56
|
-
def clean_out_uploaded_data(params,request_body)
|
57
|
-
params.each do |_, value|
|
58
|
-
if value.is_a?(Hash)
|
59
|
-
if value.has_key?(:tempfile)
|
60
|
-
data = value[:tempfile].read
|
61
|
-
request_body = request_body.gsub(data, "[uploaded data]")
|
62
|
-
else
|
63
|
-
request_body = clean_out_uploaded_data(value,request_body)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
request_body
|
68
|
-
end
|
69
|
-
|
70
56
|
def rack_test_session
|
71
57
|
@rack_test_session ||= Struct.new(:app) do
|
72
58
|
begin
|
@@ -16,7 +16,7 @@
|
|
16
16
|
<h3>{{ http_method }} {{ route }}</h3>
|
17
17
|
{{# explanation }}
|
18
18
|
<p class="explanation">
|
19
|
-
{{ explanation }}
|
19
|
+
{{{ explanation }}}
|
20
20
|
</p>
|
21
21
|
{{/ explanation }}
|
22
22
|
|
@@ -81,8 +81,10 @@
|
|
81
81
|
{{# requests }}
|
82
82
|
<h3>Request</h3>
|
83
83
|
|
84
|
-
|
85
|
-
|
84
|
+
{{# request_headers_text }}
|
85
|
+
<h4>Headers</h4>
|
86
|
+
<pre class="request headers">{{ request_headers_text }}</pre>
|
87
|
+
{{/ request_headers_text }}
|
86
88
|
|
87
89
|
<h4>Route</h4>
|
88
90
|
<pre class="request route highlight">{{ request_method }} {{ request_path }}</pre>
|
@@ -104,8 +106,10 @@
|
|
104
106
|
|
105
107
|
{{# response_status }}
|
106
108
|
<h3>Response</h3>
|
107
|
-
|
108
|
-
|
109
|
+
{{# response_headers_text }}
|
110
|
+
<h4>Headers</h4>
|
111
|
+
<pre class="response headers">{{ response_headers_text }}</pre>
|
112
|
+
{{/ response_headers_text }}
|
109
113
|
<h4>Status</h4>
|
110
114
|
<pre class="response status">{{ response_status }} {{ response_status_text}}</pre>
|
111
115
|
{{# response_body }}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec_api_documentation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Cahoon
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2015-04-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 1.4.6
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: fakefs
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -309,7 +323,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
309
323
|
version: 1.3.6
|
310
324
|
requirements: []
|
311
325
|
rubyforge_project:
|
312
|
-
rubygems_version: 2.
|
326
|
+
rubygems_version: 2.4.5
|
313
327
|
signing_key:
|
314
328
|
specification_version: 4
|
315
329
|
summary: A double black belt for your docs
|