openapi_parser 0.6.0 → 0.6.1

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: d37b73f1501e0230ab8b3bf5f8a7482809d0d1bcbc5e52ae6975442993496ffb
4
- data.tar.gz: 709cb3b9f0f65ea74abe91ff6639d8feb11f33b0c9fd2839589064b000cdc6ff
3
+ metadata.gz: 7480b22f5a7f1e12c9c1d2b21dbcc50b711bb06fba8f31e7cdff9f340f7f6fe8
4
+ data.tar.gz: d9fecd50469f7e3f8bf88cf5076c8b78df24a5d825920748f518bcbd38ca0677
5
5
  SHA512:
6
- metadata.gz: ea0e14b6b8110a0afe331bc77608d3ec7b530a8d6539d4433ed17ecf77eefaf7e0af9c56df1368a17ba65d4db75b085a57a1d5ddbb6e758202413a225c3faaac
7
- data.tar.gz: 44559dc45ab5ecaa6630d4eb848b3746a8cbce90c31d313ad9a652b188e83584aa3773b89248865510de559a9dda0f0d38575e65fae5be18195a0aec0aca80eb
6
+ metadata.gz: 18af5156bd11cd2388608f2c835cfc44a049f55e5729c25997d44a7e434f00f9278ea1b39ef5490044aa950252148585e101f021659d34fa023046af03f96401
7
+ data.tar.gz: e706defe789e26b503018653b8be22671a0155a2bbc39ac62c29603e7bd9a58f1cb923c9f7b51a858dde34ae06397860c1c68345828fff5be386866a2f6ca236
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 0.6.1 (2019-10-12)
4
+ * Bugfix: validate non-nullable response header #54
5
+ * Improve grammar in error messages #55
6
+ * fix object validator in case of properties missing #56
7
+
3
8
  ## 0.6.0 (2019-10-05)
4
9
  * add email format validation on string #51
5
10
 
@@ -13,7 +13,7 @@ module OpenAPIParser
13
13
  end
14
14
 
15
15
  def message
16
- "#{@data} class is #{@data.class} but it's not valid #{@type} in #{@reference}"
16
+ "#{@reference} expected #{@type}, but received #{@data.class}: #{@data}"
17
17
  end
18
18
 
19
19
  class << self
@@ -28,7 +28,7 @@ module OpenAPIParser
28
28
 
29
29
  class NotNullError < OpenAPIError
30
30
  def message
31
- "#{@reference} don't allow null"
31
+ "#{@reference} does not allow null values"
32
32
  end
33
33
  end
34
34
 
@@ -39,7 +39,7 @@ module OpenAPIParser
39
39
  end
40
40
 
41
41
  def message
42
- "required parameters #{@keys.join(",")} not exist in #{@reference}"
42
+ "#{@reference} missing required parameters: #{@keys.join(", ")}"
43
43
  end
44
44
  end
45
45
 
@@ -50,7 +50,7 @@ module OpenAPIParser
50
50
  end
51
51
 
52
52
  def message
53
- "properties #{@keys.join(",")} are not defined in #{@reference}"
53
+ "#{@reference} does not define properties: #{@keys.join(", ")}"
54
54
  end
55
55
  end
56
56
 
@@ -117,7 +117,7 @@ module OpenAPIParser
117
117
  end
118
118
 
119
119
  def message
120
- "#{@value} cannot be less than minimum value in #{@reference}"
120
+ "#{@reference} #{@value} is less than minimum value"
121
121
  end
122
122
  end
123
123
 
@@ -128,7 +128,7 @@ module OpenAPIParser
128
128
  end
129
129
 
130
130
  def message
131
- "#{@value} cannot be less than or equal to exclusive minimum value in #{@reference}"
131
+ "#{@reference} #{@value} cannot be less than or equal to exclusive minimum value"
132
132
  end
133
133
  end
134
134
 
@@ -139,7 +139,7 @@ module OpenAPIParser
139
139
  end
140
140
 
141
141
  def message
142
- "#{@value} cannot be more than maximum value in #{@reference}"
142
+ "#{@reference} #{@value} is more than maximum value"
143
143
  end
144
144
  end
145
145
 
@@ -150,7 +150,7 @@ module OpenAPIParser
150
150
  end
151
151
 
152
152
  def message
153
- "#{@value} cannot be more than or equal to exclusive maximum value in #{@reference}"
153
+ "#{@reference} #{@value} cannot be more than or equal to exclusive maximum value"
154
154
  end
155
155
  end
156
156
 
@@ -162,7 +162,7 @@ module OpenAPIParser
162
162
  end
163
163
 
164
164
  def message
165
- "#{@value} isn't match #{@pattern} in #{@reference}"
165
+ "#{@reference} pattern #{@pattern} does not match value: #{@value}"
166
166
  end
167
167
  end
168
168
 
@@ -173,19 +173,19 @@ module OpenAPIParser
173
173
  end
174
174
 
175
175
  def message
176
- "#{@value} is not a valid email address format in #{@reference}"
176
+ "#{@reference} email address format does not match value: #{@value}"
177
177
  end
178
178
  end
179
179
 
180
180
  class NotExistStatusCodeDefinition < OpenAPIError
181
181
  def message
182
- "don't exist status code definition in #{@reference}"
182
+ "#{@reference} status code definition does not exist"
183
183
  end
184
184
  end
185
185
 
186
186
  class NotExistContentTypeDefinition < OpenAPIError
187
187
  def message
188
- "don't exist response definition #{@reference}"
188
+ "#{@reference} response definition does not exist"
189
189
  end
190
190
  end
191
191
 
@@ -196,7 +196,7 @@ module OpenAPIParser
196
196
  end
197
197
 
198
198
  def message
199
- "#{@value} cannot be more than max length in #{@reference}"
199
+ "#{@reference} #{@value} is longer than max length"
200
200
  end
201
201
  end
202
202
 
@@ -207,7 +207,7 @@ module OpenAPIParser
207
207
  end
208
208
 
209
209
  def message
210
- "#{@value} cannot be less than min length in #{@reference}"
210
+ "#{@reference} #{@value} is shorter than min length"
211
211
  end
212
212
  end
213
213
 
@@ -218,7 +218,7 @@ module OpenAPIParser
218
218
  end
219
219
 
220
220
  def message
221
- "#{@value} cannot be more than max items in #{@reference}"
221
+ "#{@reference} #{@value} contains more than max items"
222
222
  end
223
223
  end
224
224
 
@@ -229,7 +229,7 @@ module OpenAPIParser
229
229
  end
230
230
 
231
231
  def message
232
- "#{@value} cannot be less than min items in #{@reference}"
232
+ "#{@reference} #{@value} contains fewer than min items"
233
233
  end
234
234
  end
235
235
  end
@@ -7,13 +7,13 @@ class OpenAPIParser::SchemaValidator
7
7
  def coerce_and_validate(value, schema, parent_all_of: false, discriminator_property_name: nil)
8
8
  return OpenAPIParser::ValidateError.build_error_result(value, schema) unless value.kind_of?(Hash)
9
9
 
10
- return [value, nil] unless schema.properties
10
+ properties = schema.properties || {}
11
11
 
12
12
  required_set = schema.required ? schema.required.to_set : Set.new
13
13
  remaining_keys = value.keys
14
14
 
15
15
  coerced_values = value.map do |name, v|
16
- s = schema.properties[name]
16
+ s = properties[name]
17
17
  coerced, err = if s
18
18
  remaining_keys.delete(name)
19
19
  validatable.validate_schema(v, s)
@@ -43,11 +43,11 @@ module OpenAPIParser::Schemas
43
43
  def validate_header(response_headers)
44
44
  return unless headers
45
45
 
46
- headers.each do |k, v|
47
- h = response_headers[k]
48
- next unless h
46
+ headers.each do |name, schema|
47
+ next unless response_headers.key?(name)
49
48
 
50
- v.validate(h)
49
+ value = response_headers[name]
50
+ schema.validate(value)
51
51
  end
52
52
  end
53
53
  end
@@ -1,3 +1,3 @@
1
1
  module OpenAPIParser
2
- VERSION = '0.6.0'.freeze
2
+ VERSION = '0.6.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openapi_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ota42y
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-05 00:00:00.000000000 Z
11
+ date: 2019-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler