dox 1.3.0 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/dox/util/http.rb CHANGED
@@ -2,6 +2,70 @@ module Dox
2
2
  module Util
3
3
  module Http
4
4
  VERB = ['POST', 'GET', 'PUT', 'PATCH', 'DELETE', 'HEAD'].freeze
5
+ HTTP_STATUS_CODES = {
6
+ 100 => 'Continue',
7
+ 101 => 'Switching Protocols',
8
+ 102 => 'Processing',
9
+ 103 => 'Early Hints',
10
+ 200 => 'OK',
11
+ 201 => 'Created',
12
+ 202 => 'Accepted',
13
+ 203 => 'Non-Authoritative Information',
14
+ 204 => 'No Content',
15
+ 205 => 'Reset Content',
16
+ 206 => 'Partial Content',
17
+ 207 => 'Multi-Status',
18
+ 208 => 'Already Reported',
19
+ 226 => 'IM Used',
20
+ 300 => 'Multiple Choices',
21
+ 301 => 'Moved Permanently',
22
+ 302 => 'Found',
23
+ 303 => 'See Other',
24
+ 304 => 'Not Modified',
25
+ 305 => 'Use Proxy',
26
+ 307 => 'Temporary Redirect',
27
+ 308 => 'Permanent Redirect',
28
+ 400 => 'Bad Request',
29
+ 401 => 'Unauthorized',
30
+ 402 => 'Payment Required',
31
+ 403 => 'Forbidden',
32
+ 404 => 'Not Found',
33
+ 405 => 'Method Not Allowed',
34
+ 406 => 'Not Acceptable',
35
+ 407 => 'Proxy Authentication Required',
36
+ 408 => 'Request Timeout',
37
+ 409 => 'Conflict',
38
+ 410 => 'Gone',
39
+ 411 => 'Length Required',
40
+ 412 => 'Precondition Failed',
41
+ 413 => 'Payload Too Large',
42
+ 414 => 'URI Too Long',
43
+ 415 => 'Unsupported Media Type',
44
+ 416 => 'Range Not Satisfiable',
45
+ 417 => 'Expectation Failed',
46
+ 421 => 'Misdirected Request',
47
+ 422 => 'Unprocessable Entity',
48
+ 423 => 'Locked',
49
+ 424 => 'Failed Dependency',
50
+ 425 => 'Too Early',
51
+ 426 => 'Upgrade Required',
52
+ 428 => 'Precondition Required',
53
+ 429 => 'Too Many Requests',
54
+ 431 => 'Request Header Fields Too Large',
55
+ 451 => 'Unavailable for Legal Reasons',
56
+ 500 => 'Internal Server Error',
57
+ 501 => 'Not Implemented',
58
+ 502 => 'Bad Gateway',
59
+ 503 => 'Service Unavailable',
60
+ 504 => 'Gateway Timeout',
61
+ 505 => 'HTTP Version Not Supported',
62
+ 506 => 'Variant Also Negotiates',
63
+ 507 => 'Insufficient Storage',
64
+ 508 => 'Loop Detected',
65
+ 509 => 'Bandwidth Limit Exceeded',
66
+ 510 => 'Not Extended',
67
+ 511 => 'Network Authentication Required'
68
+ }.freeze
5
69
 
6
70
  def self.verb?(value)
7
71
  VERB.include?(value.upcase)
data/lib/dox/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dox
2
- VERSION = '1.3.0'.freeze
2
+ VERSION = '2.0.0.beta1'.freeze
3
3
  end
data/lib/dox.rb CHANGED
@@ -27,7 +27,8 @@ require 'dox/formatters/xml'
27
27
  require 'dox/printers/base_printer'
28
28
  require 'dox/printers/action_printer'
29
29
  require 'dox/printers/document_printer'
30
- require 'dox/printers/example_printer'
30
+ require 'dox/printers/example_request_printer'
31
+ require 'dox/printers/example_response_printer'
31
32
  require 'dox/printers/resource_group_printer'
32
33
  require 'dox/printers/resource_printer'
33
34
  require 'dox/util/http'
@@ -48,4 +49,11 @@ module Dox
48
49
  def self.full_headers_whitelist
49
50
  (config.headers_whitelist.to_a + DEFAULT_HEADERS_WHITELIST).uniq
50
51
  end
52
+
53
+ RSpec.configure do |config|
54
+ config.after(:each, :dox) do |example|
55
+ example.metadata[:request] = request
56
+ example.metadata[:response] = response
57
+ end
58
+ end
51
59
  end
metadata CHANGED
@@ -1,74 +1,74 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 2.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Melita Kokot
8
8
  - Vedran Hrnčić
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-03-26 00:00:00.000000000 Z
12
+ date: 2020-08-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: activesupport
15
+ name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '4.0'
21
- type: :runtime
20
+ version: '0'
21
+ type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '4.0'
27
+ version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
- name: bundler
29
+ name: codeclimate-test-reporter
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: '1.11'
34
+ version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: '1.11'
41
+ version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
- name: rake
43
+ name: json
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - "~>"
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: '10.0'
48
+ version: '0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - "~>"
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: '10.0'
55
+ version: '0'
56
56
  - !ruby/object:Gem::Dependency
57
- name: rspec
57
+ name: pry-nav
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - "~>"
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: '3.0'
62
+ version: '0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - "~>"
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: '3.0'
69
+ version: '0'
70
70
  - !ruby/object:Gem::Dependency
71
- name: pry
71
+ name: pry-rails
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - ">="
@@ -82,7 +82,7 @@ dependencies:
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  - !ruby/object:Gem::Dependency
85
- name: simplecov
85
+ name: pry-stack_explorer
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - ">="
@@ -96,7 +96,63 @@ dependencies:
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  - !ruby/object:Gem::Dependency
99
- name: codeclimate-test-reporter
99
+ name: rails
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '4.0'
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '4.0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: rake
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '10.0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '10.0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: rspec
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '3.0'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '3.0'
140
+ - !ruby/object:Gem::Dependency
141
+ name: rubocop
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ - !ruby/object:Gem::Dependency
155
+ name: simplecov
100
156
  requirement: !ruby/object:Gem::Requirement
101
157
  requirements:
102
158
  - - ">="
@@ -123,7 +179,7 @@ dependencies:
123
179
  - - ">="
124
180
  - !ruby/object:Gem::Version
125
181
  version: '0'
126
- description:
182
+ description:
127
183
  email:
128
184
  - melita.kokot@gmail.com
129
185
  - vrabac266@gmail.com
@@ -174,7 +230,8 @@ files:
174
230
  - lib/dox/printers/action_printer.rb
175
231
  - lib/dox/printers/base_printer.rb
176
232
  - lib/dox/printers/document_printer.rb
177
- - lib/dox/printers/example_printer.rb
233
+ - lib/dox/printers/example_request_printer.rb
234
+ - lib/dox/printers/example_response_printer.rb
178
235
  - lib/dox/printers/resource_group_printer.rb
179
236
  - lib/dox/printers/resource_printer.rb
180
237
  - lib/dox/util/http.rb
@@ -184,7 +241,7 @@ licenses:
184
241
  - MIT
185
242
  metadata:
186
243
  allowed_push_host: https://rubygems.org
187
- post_install_message:
244
+ post_install_message:
188
245
  rdoc_options: []
189
246
  require_paths:
190
247
  - lib
@@ -195,13 +252,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
195
252
  version: 2.0.0
196
253
  required_rubygems_version: !ruby/object:Gem::Requirement
197
254
  requirements:
198
- - - ">="
255
+ - - ">"
199
256
  - !ruby/object:Gem::Version
200
- version: '0'
257
+ version: 1.3.1
201
258
  requirements: []
202
- rubyforge_project:
203
- rubygems_version: 2.5.1
204
- signing_key:
259
+ rubygems_version: 3.0.3
260
+ signing_key:
205
261
  specification_version: 4
206
- summary: Generates API documentation for rspec in api blueprint format.
262
+ summary: Generates API documentation for rspec in OpenAPI format.
207
263
  test_files: []
@@ -1,100 +0,0 @@
1
- require 'rexml/document'
2
-
3
- module Dox
4
- module Printers
5
- class ExamplePrinter < BasePrinter
6
- def print(example)
7
- self.example = example
8
- print_example_request
9
- print_example_response
10
- end
11
-
12
- private
13
-
14
- attr_accessor :example
15
-
16
- def print_example_request
17
- @output.puts example_request_title
18
- @output.puts example_request_headers
19
- return unless example.request_body.present?
20
-
21
- @output.puts example_request_body
22
- end
23
-
24
- def print_example_response
25
- @output.puts example_response_title
26
-
27
- if example.response_headers.present?
28
- @output.puts example_response_headers
29
- end
30
-
31
- return unless example.response_body.present?
32
- @output.puts example_response_body
33
- end
34
-
35
- def example_request_title
36
- <<-HEREDOC
37
-
38
- + Request #{example.request_identifier}
39
- **#{example.request_method.upcase}**&nbsp;&nbsp;`#{CGI.unescape(example.request_fullpath)}`
40
- HEREDOC
41
- end
42
-
43
- def example_request_headers
44
- <<-HEREDOC
45
-
46
- + Headers
47
-
48
- #{indent_lines(12, print_headers(example.request_headers))}
49
- HEREDOC
50
- end
51
-
52
- def example_request_body
53
- <<-HEREDOC
54
-
55
- + Body
56
-
57
- #{indent_lines(12, example.request_body)}
58
- HEREDOC
59
- end
60
-
61
- def example_response_title
62
- <<-HEREDOC
63
-
64
- + Response #{example.response_status}
65
- HEREDOC
66
- end
67
-
68
- def example_response_headers
69
- <<-HEREDOC
70
-
71
- + Headers
72
-
73
- #{indent_lines(12, print_headers(example.response_headers))}
74
- HEREDOC
75
- end
76
-
77
- def example_response_body
78
- <<-HEREDOC
79
-
80
- + Body
81
-
82
- #{indent_lines(12, example.response_body)}
83
- HEREDOC
84
- end
85
-
86
- def print_headers(headers)
87
- headers.map do |key, value|
88
- "#{key}: #{value}"
89
- end.join("\n")
90
- end
91
-
92
- def indent_lines(number_of_spaces, string)
93
- string
94
- .split("\n")
95
- .map { |a| a.prepend(' ' * number_of_spaces) }
96
- .join("\n")
97
- end
98
- end
99
- end
100
- end