lazy_api_doc 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09aa5462bb26a52e21045db9c381344ba15763862da9721008afd23e5d687a11'
4
- data.tar.gz: 6cd0d98e7896978cbe3b06504de6f46121424f7fdc910b20dfb73356aef1d3bb
3
+ metadata.gz: 31368d253e80c44fce567ac28d48de2e4ade297e3b4801633d5a71d3256da89a
4
+ data.tar.gz: d1030d418b1a8097be35afc5a0d6bb86242da3e7b59e84f8fbdc49bac383fd34
5
5
  SHA512:
6
- metadata.gz: 3723c8d550b7f2f32669ef4d3f61d4cdd9c90221cb12f0e151bd8acb72b941f554915344f16c98695928406946661117b4df0ad49b66c1e37e1f059d45b4edf9
7
- data.tar.gz: a5cb78c238bf3cfe81a620f280c73ce082bac3df6901afa041084836ad1513a6b4c63042ecffde979f6de6921cb761eb00d54d9d22f374fab3a7313f8c1e0285
6
+ metadata.gz: f223f1e4133df068b6587aa0e2cecdede3dec1c1f52e4af2946573927745aac3787fc98168ebeb149b3a2d2cef751179def7c345069abf2ce43d5f9b8b76c40d
7
+ data.tar.gz: 62281755d82ec9ac3de295d24bc108f4c462e5c08ebd8507690896dfae276acceffeff9768338ef536dc76d0907407e501c182e13b823414151c2c462961b4b7
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.7.0
1
+ ruby-3.0.3
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lazy_api_doc (0.1.5)
4
+ lazy_api_doc (0.1.6)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  ast (2.4.0)
10
10
  diff-lcs (1.3)
11
- docile (1.3.2)
11
+ docile (1.4.0)
12
12
  jaro_winkler (1.5.4)
13
13
  parallel (1.19.0)
14
14
  parser (2.6.5.0)
@@ -38,10 +38,12 @@ GEM
38
38
  rubocop-rspec (1.38.1)
39
39
  rubocop (>= 0.68.1)
40
40
  ruby-progressbar (1.10.1)
41
- simplecov (0.18.5)
41
+ simplecov (0.21.2)
42
42
  docile (~> 1.1)
43
43
  simplecov-html (~> 0.11)
44
- simplecov-html (0.12.2)
44
+ simplecov_json_formatter (~> 0.1)
45
+ simplecov-html (0.12.3)
46
+ simplecov_json_formatter (0.1.3)
45
47
  unicode-display_width (1.6.0)
46
48
 
47
49
  PLATFORMS
@@ -56,4 +58,4 @@ DEPENDENCIES
56
58
  simplecov
57
59
 
58
60
  BUNDLED WITH
59
- 2.1.2
61
+ 2.2.32
data/README.md CHANGED
@@ -45,6 +45,18 @@ The documentation will be placed `public/lazy_api_doc/api.yml`. To see it just r
45
45
 
46
46
  and navigate to http://localhost:3000/lazy_api_doc/
47
47
 
48
+ ## How does it work under the hood?
49
+
50
+ LazyApiDoc gathers your test requests and responses, group them by controllers and actions that were affected, and tries to guess the type of every field.
51
+ ```json
52
+ user: {
53
+ id: 1, // Integer
54
+ name: "John Doe", // String,
55
+ created_at: "2020-05-17 20:15:47Z -0400" // DateTime
56
+ }
57
+ ```
58
+ After that, it just builds an OpenAPI specification based on it.
59
+
48
60
  ## Contributing
49
61
 
50
62
  Bug reports and pull requests are welcome on GitHub at https://github.com/bguban/lazy_api_doc. This project is intended
@@ -3,8 +3,8 @@ module LazyApiDocInterceptor
3
3
 
4
4
  included do
5
5
  %w[get post patch put head delete].each do |method|
6
- define_method(method) do |*args|
7
- result = super(*args)
6
+ define_method(method) do |*args, **kwargs|
7
+ result = super(*args, **kwargs)
8
8
  # self.class.metadata[:doc]
9
9
  LazyApiDoc.add_test(self)
10
10
  result
@@ -3,8 +3,8 @@ module LazyApiDocInterceptor
3
3
 
4
4
  included do
5
5
  %w[get post patch put head delete].each do |method|
6
- define_method(method) do |*args|
7
- result = super(*args)
6
+ define_method(method) do |*args, **kwargs|
7
+ result = super(*args, **kwargs)
8
8
  # self.class.metadata[:doc] can be used to document only tests with doc: true metadata
9
9
  LazyApiDoc.add_spec(self)
10
10
  result
@@ -15,34 +15,19 @@ module LazyApiDoc
15
15
  def self.routes
16
16
  return @routes if defined?(@routes)
17
17
 
18
- all_routes = Rails.application.routes.routes
19
- require "action_dispatch/routing/inspector"
20
- inspector = ActionDispatch::Routing::RoutesInspector.new(all_routes)
21
- @routes = inspector.format(JsonRoutesFormatter.new, ENV["CONTROLLER"])
18
+ @routes = Rails.application.routes.routes.map { |route| format(route) }
22
19
  end
23
- end
24
- end
25
20
 
26
- class JsonRoutesFormatter
27
- def initialize
28
- @buffer = []
29
- end
21
+ def self.format(route)
22
+ route = ActionDispatch::Routing::RouteWrapper.new(route)
30
23
 
31
- def result
32
- @buffer
33
- end
34
-
35
- def section_title(_title); end
36
-
37
- def section(routes)
38
- @buffer = routes.map do |r|
39
- r[:doc_path] = r[:path].gsub("(.:format)", "").gsub(/(:\w+)/, '{\1}').delete(":")
40
- r[:path_params] = r[:path].gsub("(.:format)", "").scan(/:\w+/).map { |p| p.delete(":").to_sym }
41
- r[:controller] = r[:reqs].split("#").first
42
- r[:action] = r[:reqs].split("#").last.split(" ").first
43
- r
24
+ {
25
+ doc_path: route.path.gsub("(.:format)", "").gsub(/(:\w+)/, '{\1}').delete(":"),
26
+ path_params: route.path.gsub("(.:format)", "").scan(/:\w+/).map { |p| p.delete(":").to_sym },
27
+ controller: route.controller,
28
+ action: route.action,
29
+ verb: route.verb.split('|')
30
+ }
44
31
  end
45
32
  end
46
-
47
- def header(_routes); end
48
33
  end
@@ -1,3 +1,3 @@
1
1
  module LazyApiDoc
2
- VERSION = "0.1.5".freeze
2
+ VERSION = "0.1.6".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazy_api_doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdan Guban
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-29 00:00:00.000000000 Z
11
+ date: 2022-02-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: The gem collects all requests and responses from your request specs and
14
14
  generates documentationbased on it
@@ -51,7 +51,7 @@ metadata:
51
51
  homepage_uri: https://github.com/bguban/lazy_api_doc
52
52
  source_code_uri: https://github.com/bguban/lazy_api_doc
53
53
  changelog_uri: https://github.com/bguban/lazy_api_doc
54
- post_install_message:
54
+ post_install_message:
55
55
  rdoc_options: []
56
56
  require_paths:
57
57
  - lib
@@ -66,8 +66,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  requirements: []
69
- rubygems_version: 3.1.2
70
- signing_key:
69
+ rubygems_version: 3.2.32
70
+ signing_key:
71
71
  specification_version: 4
72
72
  summary: Creates openapi v3 documentation based on rspec request tests
73
73
  test_files: []