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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0ff0f4854e68684d59b37788218a797c61cdff744808237ca08818493a393eb
4
- data.tar.gz: 0730c2487ccb75a2fd3bec8052136cb75b9410d42daea1e3a6c9826d6854df8d
3
+ metadata.gz: 71067082bcf502d2e38341d6c357ee596851cefa9ff4e95b4ac34249261782df
4
+ data.tar.gz: '03279a96e39df1126d9fac2858903382654d2daa3121d415cf163b0bb1117fd1'
5
5
  SHA512:
6
- metadata.gz: dadb96bc250a1c615176c5ada6e5dd6a41f1dec2a96099ef5181ac83e77d9c008168c0219c0a92d59bfc7a5ca0388138bcdd2641d8c5eb767d42a38a2cbd4096
7
- data.tar.gz: 276bf5d35e634db31d6cdcaac519dac4972cbf0c93014c9c45d59a97bb0d2c20ee969c843f54e879eca8bab29cea0192cf36aab9c3ba5b0c2ee803692b0a5816
6
+ metadata.gz: 8a3344f5ee11410e189661e1ec4a6e39ab9775e2554a9a7c92818bfee71de670ec606539ccb71f60da70b727b1e8d65366507640496947e181e2bbe25251dbe2
7
+ data.tar.gz: e332d6b082d4d6215535e90b750afaf2228310f989916f7b4d1b770c972ef055f329b0c84f37dba070719b4bbee7fcb47ec7d3f0c422af66b4bd712493b51e46
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v0.4.0
2
+
3
+ * Drop `RSpec::OpenAPI.output` introduced in v0.3.20
4
+ * Guess whether it's JSON or not by the extension of `RSpec::OpenAPI.path`
5
+
1
6
  ## v0.3.20
2
7
 
3
8
  * Add `RSpec::OpenAPI.output` config to output JSON
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 yaml or json
112
- RSpec::OpenAPI.output = :json
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
- output = if json?
37
- JSON.pretty_generate(spec)
38
- else
39
- prepend_comment(YAML.dump(spec))
40
- end
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
- RSpec::OpenAPI.output.to_s == 'json'
50
+ File.extname(@path) == '.json'
57
51
  end
58
52
  end
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module OpenAPI
3
- VERSION = '0.3.20'
3
+ VERSION = '0.4.0'
4
4
  end
5
5
  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, :output
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.3.20
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.22
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