rspec-openapi 0.3.20 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +2 -2
- data/lib/rspec/openapi/schema_file.rb +8 -14
- data/lib/rspec/openapi/version.rb +1 -1
- data/lib/rspec/openapi.rb +1 -2
- 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: 71067082bcf502d2e38341d6c357ee596851cefa9ff4e95b4ac34249261782df
|
4
|
+
data.tar.gz: '03279a96e39df1126d9fac2858903382654d2daa3121d415cf163b0bb1117fd1'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a3344f5ee11410e189661e1ec4a6e39ab9775e2554a9a7c92818bfee71de670ec606539ccb71f60da70b727b1e8d65366507640496947e181e2bbe25251dbe2
|
7
|
+
data.tar.gz: e332d6b082d4d6215535e90b750afaf2228310f989916f7b4d1b770c972ef055f329b0c84f37dba070719b4bbee7fcb47ec7d3f0c422af66b4bd712493b51e46
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -108,8 +108,8 @@ The following configurations are optional.
|
|
108
108
|
# Change the path to generate schema from `doc/openapi.yaml`
|
109
109
|
RSpec::OpenAPI.path = 'doc/schema.yaml'
|
110
110
|
|
111
|
-
# Change the output type
|
112
|
-
RSpec::OpenAPI.
|
111
|
+
# Change the output type to JSON
|
112
|
+
RSpec::OpenAPI.path = 'doc/schema.json'
|
113
113
|
|
114
114
|
# Disable generating `example`
|
115
115
|
RSpec::OpenAPI.enable_example = false
|
@@ -21,24 +21,18 @@ class RSpec::OpenAPI::SchemaFile
|
|
21
21
|
# @return [Hash]
|
22
22
|
def read
|
23
23
|
return {} unless File.exist?(@path)
|
24
|
-
|
25
|
-
content = File.read(@path)
|
26
|
-
|
27
|
-
return JSON.load(content) if json?
|
28
|
-
|
29
|
-
YAML.load(content)
|
24
|
+
YAML.load(File.read(@path)) # this can also parse JSON
|
30
25
|
end
|
31
26
|
|
32
27
|
# @param [Hash] spec
|
33
28
|
def write(spec)
|
34
29
|
FileUtils.mkdir_p(File.dirname(@path))
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
30
|
+
output =
|
31
|
+
if json?
|
32
|
+
JSON.pretty_generate(spec)
|
33
|
+
else
|
34
|
+
prepend_comment(YAML.dump(spec))
|
35
|
+
end
|
42
36
|
File.write(@path, output)
|
43
37
|
end
|
44
38
|
|
@@ -53,6 +47,6 @@ class RSpec::OpenAPI::SchemaFile
|
|
53
47
|
end
|
54
48
|
|
55
49
|
def json?
|
56
|
-
|
50
|
+
File.extname(@path) == '.json'
|
57
51
|
end
|
58
52
|
end
|
data/lib/rspec/openapi.rb
CHANGED
@@ -7,11 +7,10 @@ module RSpec::OpenAPI
|
|
7
7
|
@enable_example = true
|
8
8
|
@description_builder = -> (example) { example.description }
|
9
9
|
@application_version = '1.0.0'
|
10
|
-
@output = :yaml
|
11
10
|
@request_headers = []
|
12
11
|
@server_urls = []
|
13
12
|
|
14
13
|
class << self
|
15
|
-
attr_accessor :path, :comment, :enable_example, :description_builder, :application_version, :request_headers, :server_urls
|
14
|
+
attr_accessor :path, :comment, :enable_example, :description_builder, :application_version, :request_headers, :server_urls
|
16
15
|
end
|
17
16
|
end
|
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.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
92
|
requirements: []
|
93
|
-
rubygems_version: 3.2
|
93
|
+
rubygems_version: 3.1.2
|
94
94
|
signing_key:
|
95
95
|
specification_version: 4
|
96
96
|
summary: Generate OpenAPI schema from RSpec request specs
|