rspec-openapi 0.18.2 → 0.18.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rspec/openapi/extractors/hanami.rb +3 -10
- data/lib/rspec/openapi/extractors.rb +0 -7
- data/lib/rspec/openapi/version.rb +1 -1
- data/lib/rspec/openapi.rb +31 -21
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39da96c0f0b1650e0504d45a624be7905c9f47a2b128e992eecb5b05b828dd87
|
4
|
+
data.tar.gz: 5c6cb0fdaf3900ae93d0618c82b6762c8cf50002e7ac155c23a46b543f91d126
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df87ce7e2b08623ec314330020d011ede771872a435f11b266be1f1c1a2e24c8329559b1f3e42b50a58a86c442c0afed2e98444694138823b9b17ebb94e54878
|
7
|
+
data.tar.gz: c89fb952a0d8fbc4c5ed814bd11513d2323f2c5237ad0a7b0e341e2522c329a331230b51ecab3bcf42a60dd4e5da090a337202dac37db3d4f68ab82ad7a9f91b
|
@@ -19,10 +19,7 @@ class Inspector
|
|
19
19
|
def call(verb, path)
|
20
20
|
route = routes.find { |r| r.http_method == verb && r.path == path }
|
21
21
|
|
22
|
-
if route.
|
23
|
-
# FIXME: This is a hack to pass `/sites/***` in testing
|
24
|
-
{}
|
25
|
-
elsif route.to.is_a?(Proc)
|
22
|
+
if route.to.is_a?(Proc)
|
26
23
|
{
|
27
24
|
tags: [],
|
28
25
|
summary: "#{verb} #{path}",
|
@@ -55,7 +52,7 @@ class << RSpec::OpenAPI::Extractors::Hanami = Object.new
|
|
55
52
|
# @param [RSpec::Core::Example] example
|
56
53
|
# @return Array
|
57
54
|
def request_attributes(request, example)
|
58
|
-
route = Hanami.app.router.recognize(request.path, method: request.method)
|
55
|
+
route = Hanami.app.router.recognize(Rack::MockRequest.env_for(request.path, method: request.method))
|
59
56
|
|
60
57
|
return RSpec::OpenAPI::Extractors::Rack.request_attributes(request, example) unless route.routable?
|
61
58
|
|
@@ -69,7 +66,7 @@ class << RSpec::OpenAPI::Extractors::Hanami = Object.new
|
|
69
66
|
deprecated = metadata[:deprecated]
|
70
67
|
path = request.path
|
71
68
|
|
72
|
-
raw_path_params = route.params
|
69
|
+
raw_path_params = route.params
|
73
70
|
|
74
71
|
result = InspectorAnalyzer.call(request.method, add_id(path, route))
|
75
72
|
|
@@ -95,8 +92,6 @@ class << RSpec::OpenAPI::Extractors::Hanami = Object.new
|
|
95
92
|
return path if route.params.empty?
|
96
93
|
|
97
94
|
route.params.each_pair do |key, value|
|
98
|
-
next unless RSpec::OpenAPI::Extractors.number_or_nil(value)
|
99
|
-
|
100
95
|
path = path.sub("/#{value}", "/:#{key}")
|
101
96
|
end
|
102
97
|
|
@@ -107,8 +102,6 @@ class << RSpec::OpenAPI::Extractors::Hanami = Object.new
|
|
107
102
|
return path if route.params.empty?
|
108
103
|
|
109
104
|
route.params.each_pair do |key, value|
|
110
|
-
next unless RSpec::OpenAPI::Extractors.number_or_nil(value)
|
111
|
-
|
112
105
|
path = path.sub("/#{value}", "/{#{key}}")
|
113
106
|
end
|
114
107
|
|
data/lib/rspec/openapi.rb
CHANGED
@@ -15,30 +15,17 @@ require 'rspec/openapi/shared_hooks'
|
|
15
15
|
require 'rspec/openapi/extractors'
|
16
16
|
require 'rspec/openapi/extractors/rack'
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
require 'hanami'
|
23
|
-
rescue LoadError
|
24
|
-
warn 'Hanami not detected' if DEBUG_ENABLED
|
25
|
-
else
|
26
|
-
require 'rspec/openapi/extractors/hanami'
|
27
|
-
end
|
18
|
+
module RSpec::OpenAPI
|
19
|
+
class Config
|
20
|
+
class << self
|
21
|
+
attr_accessor :debug_enabled
|
28
22
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
else
|
34
|
-
require 'rspec/openapi/extractors/rails'
|
23
|
+
def load_environment_settings
|
24
|
+
@debug_enabled = ['', '1', 'true'].include?(ENV['DEBUG']&.downcase)
|
25
|
+
end
|
26
|
+
end
|
35
27
|
end
|
36
|
-
end
|
37
28
|
|
38
|
-
require 'rspec/openapi/minitest_hooks' if Object.const_defined?('Minitest')
|
39
|
-
require 'rspec/openapi/rspec_hooks' if ENV['OPENAPI'] && Object.const_defined?('RSpec')
|
40
|
-
|
41
|
-
module RSpec::OpenAPI
|
42
29
|
@path = 'doc/openapi.yaml'
|
43
30
|
@title = File.basename(Dir.pwd)
|
44
31
|
@comment = nil
|
@@ -84,3 +71,26 @@ module RSpec::OpenAPI
|
|
84
71
|
attr_reader :config_filename
|
85
72
|
end
|
86
73
|
end
|
74
|
+
|
75
|
+
if ENV['OPENAPI']
|
76
|
+
RSpec::OpenAPI::Config.load_environment_settings
|
77
|
+
|
78
|
+
begin
|
79
|
+
require 'hanami'
|
80
|
+
rescue LoadError
|
81
|
+
warn 'Hanami not detected' if RSpec::OpenAPI::Config.debug_enabled
|
82
|
+
else
|
83
|
+
require 'rspec/openapi/extractors/hanami'
|
84
|
+
end
|
85
|
+
|
86
|
+
begin
|
87
|
+
require 'rails'
|
88
|
+
rescue LoadError
|
89
|
+
warn 'Rails not detected' if RSpec::OpenAPI::Config.debug_enabled
|
90
|
+
else
|
91
|
+
require 'rspec/openapi/extractors/rails'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
require 'rspec/openapi/minitest_hooks' if Object.const_defined?('Minitest')
|
96
|
+
require 'rspec/openapi/rspec_hooks' if ENV['OPENAPI'] && Object.const_defined?('RSpec')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-openapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.18.
|
4
|
+
version: 0.18.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-05-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -109,7 +109,7 @@ licenses:
|
|
109
109
|
metadata:
|
110
110
|
homepage_uri: https://github.com/exoego/rspec-openapi
|
111
111
|
source_code_uri: https://github.com/exoego/rspec-openapi
|
112
|
-
changelog_uri: https://github.com/exoego/rspec-openapi/releases/tag/v0.18.
|
112
|
+
changelog_uri: https://github.com/exoego/rspec-openapi/releases/tag/v0.18.3
|
113
113
|
rubygems_mfa_required: 'true'
|
114
114
|
post_install_message:
|
115
115
|
rdoc_options: []
|