rspec-openapi 0.2.1 → 0.2.2

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: cb2aae5a8366967c1ce6a904bb990372af7f5d3b09d4c81fad3866e590c168c3
4
- data.tar.gz: 0665f9348a14cb0eb77c37368f69d3952d6eb71e919d8864931cdfbbbc3055dc
3
+ metadata.gz: 11f6fd4a506ac6f481fa67c33e2bacecba3ee4e568339338acf4237f4f599bac
4
+ data.tar.gz: 45ea7bbf466a413d3eb5d32ae19a38591c542431eee4dcb21905b8070b2280ac
5
5
  SHA512:
6
- metadata.gz: 69ec6408d396d9e4c75bc4ba3ef1c71f82ea2a7bbd67def082262b275c20b9769db851fdb2c1bea971a4ede35c10b6f325fbc35a73be8591f12a986e94a01637
7
- data.tar.gz: b71662890f9710012a329db3f380f831e10a8d37671fd9db2a9e3b84d237c699c0c40892020e4f20c781b36ab68563205208bc51607f73f5b2f002c80b5c48de
6
+ metadata.gz: 3b98372303bb006dba766c0b48218c4be8a45a84f470d6cdfc40b3e7f9d780edb484ca58373239a6aeeba83c7f4c8c3daf8c241cdcb903cc1158c80c92269203
7
+ data.tar.gz: 8a198194bdc3e4bf0d09f6fe66b1893da1eaa4b0333c1168b9bd309ba26634ab16d53342c140f8d7b4c0f31e02cfc1ba9629b5dc12905dfc5e6eb35990f23c30
@@ -1,3 +1,7 @@
1
+ ## v0.2.2
2
+
3
+ * Allow disabling `example` by `RSpec::OpenAPI.enable_example = false`
4
+
1
5
  ## v0.2.1
2
6
 
3
7
  * Generate `example` of request body and path / query params
data/README.md CHANGED
@@ -104,6 +104,9 @@ The following configurations are optional.
104
104
  # Change the path to generate schema from `doc/openapi.yaml`
105
105
  RSpec::OpenAPI.path = 'doc/schema.yaml'
106
106
 
107
+ # Disable generating `example`
108
+ RSpec::OpenAPI.enable_example = false
109
+
107
110
  # Generate a comment on top of a schema file
108
111
  RSpec::OpenAPI.comment = <<~EOS
109
112
  This file is auto-generated by rspec-openapi https://github.com/k0kubun/rspec-openapi
@@ -138,9 +141,9 @@ end
138
141
 
139
142
  ## Project status
140
143
 
141
- PoC / Experimental
144
+ Beta
142
145
 
143
- This worked for some of my Rails apps, but this may raise a basic error for your app.
146
+ Basic features are there, and some people are already using this.
144
147
 
145
148
  ### Current limitations
146
149
 
@@ -3,8 +3,10 @@ require 'rspec/openapi/hooks' if ENV['OPENAPI']
3
3
 
4
4
  module RSpec::OpenAPI
5
5
  @path = 'doc/openapi.yaml'
6
+ @comment = nil
7
+ @enable_example = true
6
8
 
7
9
  class << self
8
- attr_accessor :path, :comment
10
+ attr_accessor :path, :comment, :enable_example
9
11
  end
10
12
  end
@@ -15,8 +15,8 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
15
15
  content: {
16
16
  normalize_content_type(record.response_content_type) => {
17
17
  schema: build_property(record.response_body),
18
- example: record.response_body,
19
- },
18
+ example: (record.response_body if example_enabled?),
19
+ }.compact,
20
20
  },
21
21
  },
22
22
  },
@@ -28,6 +28,10 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
28
28
 
29
29
  private
30
30
 
31
+ def example_enabled?
32
+ RSpec::OpenAPI.enable_example
33
+ end
34
+
31
35
  def build_parameters(record)
32
36
  parameters = []
33
37
 
@@ -38,8 +42,8 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
38
42
  in: 'path',
39
43
  required: true,
40
44
  schema: build_property(try_cast(value)),
41
- example: try_cast(value),
42
- }
45
+ example: (try_cast(value) if example_enabled?),
46
+ }.compact
43
47
  end
44
48
 
45
49
  record.query_params.each do |key, value|
@@ -47,8 +51,8 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
47
51
  name: key.to_s,
48
52
  in: 'query',
49
53
  schema: build_property(try_cast(value)),
50
- example: try_cast(value),
51
- }
54
+ example: (try_cast(value) if example_enabled?),
55
+ }.compact
52
56
  end
53
57
 
54
58
  return nil if parameters.empty?
@@ -63,8 +67,8 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
63
67
  content: {
64
68
  normalize_content_type(record.request_content_type) => {
65
69
  schema: build_property(record.request_params),
66
- example: record.request_params,
67
- }
70
+ example: (record.request_params if example_enabled?),
71
+ }.compact
68
72
  }
69
73
  }
70
74
  end
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module OpenAPI
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.2'
4
4
  end
5
5
  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.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-25 00:00:00.000000000 Z
11
+ date: 2020-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  requirements: []
77
- rubygems_version: 3.2.0.pre1
77
+ rubygems_version: 3.1.2
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: Generate OpenAPI schema from RSpec request specs