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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +5 -2
- data/lib/rspec/openapi.rb +3 -1
- data/lib/rspec/openapi/schema_builder.rb +12 -8
- data/lib/rspec/openapi/version.rb +1 -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: 11f6fd4a506ac6f481fa67c33e2bacecba3ee4e568339338acf4237f4f599bac
|
4
|
+
data.tar.gz: 45ea7bbf466a413d3eb5d32ae19a38591c542431eee4dcb21905b8070b2280ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b98372303bb006dba766c0b48218c4be8a45a84f470d6cdfc40b3e7f9d780edb484ca58373239a6aeeba83c7f4c8c3daf8c241cdcb903cc1158c80c92269203
|
7
|
+
data.tar.gz: 8a198194bdc3e4bf0d09f6fe66b1893da1eaa4b0333c1168b9bd309ba26634ab16d53342c140f8d7b4c0f31e02cfc1ba9629b5dc12905dfc5e6eb35990f23c30
|
data/CHANGELOG.md
CHANGED
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
|
-
|
144
|
+
Beta
|
142
145
|
|
143
|
-
|
146
|
+
Basic features are there, and some people are already using this.
|
144
147
|
|
145
148
|
### Current limitations
|
146
149
|
|
data/lib/rspec/openapi.rb
CHANGED
@@ -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
|
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.
|
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-
|
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
|
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
|