openapi_parser 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/openapi_parser/schema_validator.rb +17 -1
- data/lib/openapi_parser/schema_validators/enumable.rb +3 -0
- data/lib/openapi_parser/schema_validators/float_validator.rb +4 -1
- data/lib/openapi_parser/schema_validators/integer_validator.rb +3 -0
- data/lib/openapi_parser/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fc5651f9e70c443d358fce4dc0e03bb6ecddf38f4862add79ed36f7a0b2a516
|
4
|
+
data.tar.gz: 153339ab41b7a1d3b9bbf3299b53dce0ce57b4c3cf544bb5cf6dee64e98429f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d116f2b5e22b12cfce469d423e21a711703efaabd04789867fa8dfc312c7818a253bf6a66d6eb437119534d61e02f27dad723f6ce003356a5567f97aded6969
|
7
|
+
data.tar.gz: c69e9b18b3bc0933287602050386800c6f530fe899217665b92044bebf0a6a4f54f124d36b22ceda11259e35dc78cfb2ef1db6bdd33a57b96ed80e162c770c41
|
data/CHANGELOG.md
CHANGED
@@ -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
|
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
|
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
|
|
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.
|
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-
|
11
|
+
date: 2018-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|