rspec-openapi 0.3.19 → 0.3.20
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 +3 -4
- data/lib/rspec/openapi/schema_file.rb +19 -2
- data/lib/rspec/openapi/version.rb +1 -1
- data/lib/rspec/openapi.rb +2 -1
- 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: d0ff0f4854e68684d59b37788218a797c61cdff744808237ca08818493a393eb
|
4
|
+
data.tar.gz: 0730c2487ccb75a2fd3bec8052136cb75b9410d42daea1e3a6c9826d6854df8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dadb96bc250a1c615176c5ada6e5dd6a41f1dec2a96099ef5181ac83e77d9c008168c0219c0a92d59bfc7a5ca0388138bcdd2641d8c5eb767d42a38a2cbd4096
|
7
|
+
data.tar.gz: 276bf5d35e634db31d6cdcaac519dac4972cbf0c93014c9c45d59a97bb0d2c20ee969c843f54e879eca8bab29cea0192cf36aab9c3ba5b0c2ee803692b0a5816
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -108,6 +108,9 @@ 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 yaml or json
|
112
|
+
RSpec::OpenAPI.output = :json
|
113
|
+
|
111
114
|
# Disable generating `example`
|
112
115
|
RSpec::OpenAPI.enable_example = false
|
113
116
|
|
@@ -163,10 +166,6 @@ Beta
|
|
163
166
|
|
164
167
|
Basic features are there, and some people are already using this.
|
165
168
|
|
166
|
-
### Current limitation
|
167
|
-
|
168
|
-
* Generating a JSON file is not supported yet
|
169
|
-
|
170
169
|
### Other missing features with notes
|
171
170
|
|
172
171
|
* Delete obsoleted endpoints
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'yaml'
|
3
|
+
require 'json'
|
3
4
|
|
4
5
|
# TODO: Support JSON
|
5
6
|
class RSpec::OpenAPI::SchemaFile
|
@@ -20,13 +21,25 @@ class RSpec::OpenAPI::SchemaFile
|
|
20
21
|
# @return [Hash]
|
21
22
|
def read
|
22
23
|
return {} unless File.exist?(@path)
|
23
|
-
|
24
|
+
|
25
|
+
content = File.read(@path)
|
26
|
+
|
27
|
+
return JSON.load(content) if json?
|
28
|
+
|
29
|
+
YAML.load(content)
|
24
30
|
end
|
25
31
|
|
26
32
|
# @param [Hash] spec
|
27
33
|
def write(spec)
|
28
34
|
FileUtils.mkdir_p(File.dirname(@path))
|
29
|
-
|
35
|
+
|
36
|
+
output = if json?
|
37
|
+
JSON.pretty_generate(spec)
|
38
|
+
else
|
39
|
+
prepend_comment(YAML.dump(spec))
|
40
|
+
end
|
41
|
+
|
42
|
+
File.write(@path, output)
|
30
43
|
end
|
31
44
|
|
32
45
|
def prepend_comment(content)
|
@@ -38,4 +51,8 @@ class RSpec::OpenAPI::SchemaFile
|
|
38
51
|
end
|
39
52
|
"#{comment.gsub(/^/, '# ').gsub(/^# \n/, "#\n")}#{content}"
|
40
53
|
end
|
54
|
+
|
55
|
+
def json?
|
56
|
+
RSpec::OpenAPI.output.to_s == 'json'
|
57
|
+
end
|
41
58
|
end
|
data/lib/rspec/openapi.rb
CHANGED
@@ -7,10 +7,11 @@ 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
|
10
11
|
@request_headers = []
|
11
12
|
@server_urls = []
|
12
13
|
|
13
14
|
class << self
|
14
|
-
attr_accessor :path, :comment, :enable_example, :description_builder, :application_version, :request_headers, :server_urls
|
15
|
+
attr_accessor :path, :comment, :enable_example, :description_builder, :application_version, :request_headers, :server_urls, :output
|
15
16
|
end
|
16
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-openapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -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.
|
93
|
+
rubygems_version: 3.2.22
|
94
94
|
signing_key:
|
95
95
|
specification_version: 4
|
96
96
|
summary: Generate OpenAPI schema from RSpec request specs
|