openapi_parser 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/openapi_parser/errors.rb +11 -0
- data/lib/openapi_parser/schema_validators/string_validator.rb +14 -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: d37b73f1501e0230ab8b3bf5f8a7482809d0d1bcbc5e52ae6975442993496ffb
|
4
|
+
data.tar.gz: 709cb3b9f0f65ea74abe91ff6639d8feb11f33b0c9fd2839589064b000cdc6ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea0e14b6b8110a0afe331bc77608d3ec7b530a8d6539d4433ed17ecf77eefaf7e0af9c56df1368a17ba65d4db75b085a57a1d5ddbb6e758202413a225c3faaac
|
7
|
+
data.tar.gz: 44559dc45ab5ecaa6630d4eb848b3746a8cbce90c31d313ad9a652b188e83584aa3773b89248865510de559a9dda0f0d38575e65fae5be18195a0aec0aca80eb
|
data/CHANGELOG.md
CHANGED
@@ -166,6 +166,17 @@ module OpenAPIParser
|
|
166
166
|
end
|
167
167
|
end
|
168
168
|
|
169
|
+
class InvalidEmailFormat < OpenAPIError
|
170
|
+
def initialize(value, reference)
|
171
|
+
super(reference)
|
172
|
+
@value = value
|
173
|
+
end
|
174
|
+
|
175
|
+
def message
|
176
|
+
"#{@value} is not a valid email address format in #{@reference}"
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
169
180
|
class NotExistStatusCodeDefinition < OpenAPIError
|
170
181
|
def message
|
171
182
|
"don't exist status code definition in #{@reference}"
|
@@ -24,6 +24,9 @@ class OpenAPIParser::SchemaValidator
|
|
24
24
|
value, err = validate_max_min_length(value, schema)
|
25
25
|
return [nil, err] if err
|
26
26
|
|
27
|
+
value, err = validate_email_format(value, schema)
|
28
|
+
return [nil, err] if err
|
29
|
+
|
27
30
|
[value, nil]
|
28
31
|
end
|
29
32
|
|
@@ -61,5 +64,16 @@ class OpenAPIParser::SchemaValidator
|
|
61
64
|
|
62
65
|
[value, nil]
|
63
66
|
end
|
67
|
+
|
68
|
+
def validate_email_format(value, schema)
|
69
|
+
return [value, nil] unless schema.format == 'email'
|
70
|
+
|
71
|
+
# match? method is good performance.
|
72
|
+
# So when we drop ruby 2.3 support we use match? method because this method add ruby 2.4
|
73
|
+
#return [value, nil] if value.match?(URI::MailTo::EMAIL_REGEXP)
|
74
|
+
return [value, nil] if value.match(URI::MailTo::EMAIL_REGEXP)
|
75
|
+
|
76
|
+
return [nil, OpenAPIParser::InvalidEmailFormat.new(value, schema.object_reference)]
|
77
|
+
end
|
64
78
|
end
|
65
79
|
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.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ota42y
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|