openapi_parser 0.1.6 → 0.1.7

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: e0035d4ece30f151226f04a1462ae6cf4d54c36011b315810bd49588f66b0632
4
- data.tar.gz: cae26e5b18e0ab71b2027d56a828cccd737126852b96c68facf88f8ba27db0ab
3
+ metadata.gz: 8fc5651f9e70c443d358fce4dc0e03bb6ecddf38f4862add79ed36f7a0b2a516
4
+ data.tar.gz: 153339ab41b7a1d3b9bbf3299b53dce0ce57b4c3cf544bb5cf6dee64e98429f7
5
5
  SHA512:
6
- metadata.gz: 0456ee6d9363ff05c1ef517cbc9aa8cfbcad55aa054e012009ec685a5b97c7779c897842918a868dae3acefa143bbfa7790fc7bb1ba370e04293fc7ead130ef4
7
- data.tar.gz: d2855d0574bfdc5a769576ffa89af5d1006f960af4a4790e92edfbe5763eb3a954698f71522d599524b1b9d906f11632440167c4e37e524435804873aeede533
6
+ metadata.gz: 6d116f2b5e22b12cfce469d423e21a711703efaabd04789867fa8dfc312c7818a253bf6a66d6eb437119534d61e02f27dad723f6ce003356a5567f97aded6969
7
+ data.tar.gz: c69e9b18b3bc0933287602050386800c6f530fe899217665b92044bebf0a6a4f54f124d36b22ceda11259e35dc78cfb2ef1db6bdd33a57b96ed80e162c770c41
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 0.1.7 (2018-12-30)
4
+ * Float value validate bugfix (#15)
5
+
3
6
  ## 0.1.6 (2018-12-29)
4
7
  * Support allOf definition (#11)
5
8
  * Support wildcard status code (#12)
@@ -20,6 +20,14 @@ class OpenAPIParser::SchemaValidator
20
20
  def validate_schema(value, schema)
21
21
  raise 'implement'
22
22
  end
23
+
24
+ # validate integer value by schema
25
+ # this method use from float_validator because number allow float and integer
26
+ # @param [Object] _value
27
+ # @param [OpenAPIParser::Schemas::Schema] _schema
28
+ def validate_integer(_value, _schema)
29
+ raise 'implement'
30
+ end
23
31
  end
24
32
 
25
33
  include Validatable
@@ -27,7 +35,7 @@ class OpenAPIParser::SchemaValidator
27
35
  class << self
28
36
  # validate schema data
29
37
  # @param [Hash] value
30
- # @param [OpenAPIParser::Schemas::Schema]
38
+ # @param [OpenAPIParser::Schemas:v:Schema]
31
39
  # @param [OpenAPIParser::SchemaValidator::Options] options
32
40
  # @return [Object] coerced or original params
33
41
  def validate(value, schema, options)
@@ -68,6 +76,14 @@ class OpenAPIParser::SchemaValidator
68
76
  OpenAPIParser::ValidateError.build_error_result(value, schema)
69
77
  end
70
78
 
79
+ # validate integer value by schema
80
+ # this method use from float_validator because number allow float and integer
81
+ # @param [Object] value
82
+ # @param [OpenAPIParser::Schemas::Schema] schema
83
+ def validate_integer(value, schema)
84
+ integer_validator.coerce_and_validate(value, schema)
85
+ end
86
+
71
87
  private
72
88
 
73
89
  # @return [OpenAPIParser::SchemaValidator::Base, nil]
@@ -1,5 +1,8 @@
1
1
  class OpenAPIParser::SchemaValidator
2
2
  module Enumable
3
+ # check enum value by schema
4
+ # @param [Object] value
5
+ # @param [OpenAPIParser::Schemas::Schema] schema
3
6
  def check_enum_include(value, schema)
4
7
  return [value, nil] unless schema.enum
5
8
  return [value, nil] if schema.enum.include?(value)
@@ -2,10 +2,13 @@ class OpenAPIParser::SchemaValidator
2
2
  class FloatValidator < Base
3
3
  include ::OpenAPIParser::SchemaValidator::Enumable
4
4
 
5
+ # validate float value by schema
6
+ # @param [Object] value
7
+ # @param [OpenAPIParser::Schemas::Schema] schema
5
8
  def coerce_and_validate(value, schema)
6
9
  value = coerce(value) if @coerce_value
7
10
 
8
- return OpenAPIParser::ValidateError.build_error_result(value, schema) if value.kind_of?(Integer)
11
+ return validatable.validate_integer(value, schema) if value.kind_of?(Integer)
9
12
 
10
13
  coercer_and_validate_numeric(value, schema)
11
14
  end
@@ -2,6 +2,9 @@ class OpenAPIParser::SchemaValidator
2
2
  class IntegerValidator < Base
3
3
  include ::OpenAPIParser::SchemaValidator::Enumable
4
4
 
5
+ # validate integer value by schema
6
+ # @param [Object] value
7
+ # @param [OpenAPIParser::Schemas::Schema] schema
5
8
  def coerce_and_validate(value, schema)
6
9
  value = coerce(value) if @coerce_value
7
10
 
@@ -1,3 +1,3 @@
1
1
  module OpenAPIParser
2
- VERSION = '0.1.6'.freeze
2
+ VERSION = '0.1.7'.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.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - ota42y
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-29 00:00:00.000000000 Z
11
+ date: 2018-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler