openapi_rspec 0.2.2 → 0.3
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 +4 -4
- data/lib/openapi_rspec.rb +19 -0
- data/lib/openapi_rspec/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0367f850252eff7b267d205f702bb3424a10f88d3333b700f416fc337879ede2
|
4
|
+
data.tar.gz: ba6f7e1e9f0a8a706c6d5f712d50e2c5f916e56201a1131cd73505c6ceec4ce1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3104ab50af0749801e8a31b422f67c905f76cf75059aa5ba1121008a30990cdce08f941808914cb730b64f7a363bf5a4a839ad682b90a26352b3264b801bc445
|
7
|
+
data.tar.gz: eb0a1de49ad9adea06094c06b34d250b4f95f359dedc4c78ccf1e18d98cc5c0a93ec2e6afc1ab1a5fb54bda68827a679f49a24aa46c3680c9b44dc2103fa4913
|
data/lib/openapi_rspec.rb
CHANGED
@@ -18,6 +18,25 @@ module OpenapiRspec
|
|
18
18
|
OpenapiValidator.call(doc, **params)
|
19
19
|
end
|
20
20
|
|
21
|
+
def self.api_by_path(openapi_path, **params)
|
22
|
+
session = Rack::Test::Session.new(config.app)
|
23
|
+
begin
|
24
|
+
response = session.get(openapi_path)
|
25
|
+
rescue StandardError => e
|
26
|
+
raise "Unable to perform GET request for swagger json: #{openapi_path} - #{e}."
|
27
|
+
end
|
28
|
+
|
29
|
+
parsed_doc = case openapi_path.split(".").last
|
30
|
+
when "yml", "yaml"
|
31
|
+
YAML.load(response.body)
|
32
|
+
when "json"
|
33
|
+
JSON.parse(response.body)
|
34
|
+
else
|
35
|
+
raise "Unable to parse OpenAPI doc, '#{openapi_path}' is undefined format"
|
36
|
+
end
|
37
|
+
OpenapiValidator.call(parsed_doc, **params)
|
38
|
+
end
|
39
|
+
|
21
40
|
RSpec.configure do |config|
|
22
41
|
config.extend ModuleHelpers
|
23
42
|
config.include Helpers
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openapi_rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Svyatoslav Kryukov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|