oas_parser 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/lib/oas_parser.rb +1 -0
- data/lib/oas_parser/abstract_attribute.rb +48 -0
- data/lib/oas_parser/parameter.rb +1 -20
- data/lib/oas_parser/property.rb +1 -20
- data/lib/oas_parser/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3c162b9a3ad868ac7bd502154850707c02d1b1c
|
4
|
+
data.tar.gz: 7ff14242ea28262097ec1cc3d21adf2ca70d7004
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87d32af56fe2cd99ed3353b128e143a724f8704948cabf8e1b57697130c24559af55ef045d3ecd36c3cb8cc517e52245bc53c252aadf2ddeceafe6ad16a355ed
|
7
|
+
data.tar.gz: 5ba21605bd9d4af9b25369d57ffcc7989985c06a3bd1317338efc53eff0afb68e186054d7d8dfa73cbe37f990a9c65f00fa94be0134422f5066eab5da6a3a7e5
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
oas_parser (0.
|
4
|
+
oas_parser (0.8.0)
|
5
5
|
activesupport (~> 5.1.2)
|
6
6
|
addressable (~> 2.3)
|
7
7
|
builder (~> 3.2.3)
|
@@ -26,7 +26,7 @@ GEM
|
|
26
26
|
deep_merge (1.2.1)
|
27
27
|
diff-lcs (1.3)
|
28
28
|
docile (1.1.5)
|
29
|
-
ffi (1.9.
|
29
|
+
ffi (1.9.21)
|
30
30
|
formatador (0.2.5)
|
31
31
|
guard (2.14.2)
|
32
32
|
formatador (>= 0.2.4)
|
@@ -90,7 +90,7 @@ GEM
|
|
90
90
|
simplecov-html (0.10.2)
|
91
91
|
thor (0.20.0)
|
92
92
|
thread_safe (0.3.6)
|
93
|
-
tzinfo (1.2.
|
93
|
+
tzinfo (1.2.5)
|
94
94
|
thread_safe (~> 0.1)
|
95
95
|
|
96
96
|
PLATFORMS
|
data/lib/oas_parser.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
module OasParser
|
2
|
+
class AbstractAttribute
|
3
|
+
include OasParser::RawAccessor
|
4
|
+
|
5
|
+
def array?
|
6
|
+
type == 'array'
|
7
|
+
end
|
8
|
+
|
9
|
+
def object?
|
10
|
+
type == 'object'
|
11
|
+
end
|
12
|
+
|
13
|
+
def collection?
|
14
|
+
array? || object?
|
15
|
+
end
|
16
|
+
|
17
|
+
def properties
|
18
|
+
return convert_property_schema_to_properties(raw['properties']) if object?
|
19
|
+
return convert_property_schema_to_properties(items) if array?
|
20
|
+
nil
|
21
|
+
end
|
22
|
+
|
23
|
+
def has_xml_options?
|
24
|
+
raw['xml'].present?
|
25
|
+
end
|
26
|
+
|
27
|
+
def is_xml_attribute?
|
28
|
+
return false unless has_xml_options?
|
29
|
+
raw['xml']['attribute'] || false
|
30
|
+
end
|
31
|
+
|
32
|
+
def is_xml_text?
|
33
|
+
# See: https://github.com/OAI/OpenAPI-Specification/issues/630#issuecomment-350680346
|
34
|
+
return false unless has_xml_options?
|
35
|
+
return true if raw['xml']['text'] || false
|
36
|
+
raw['xml']['x-text'] || false
|
37
|
+
end
|
38
|
+
|
39
|
+
def has_xml_name?
|
40
|
+
return false unless has_xml_options?
|
41
|
+
xml_name || false
|
42
|
+
end
|
43
|
+
|
44
|
+
def xml_name
|
45
|
+
raw['xml']['name']
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/oas_parser/parameter.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module OasParser
|
2
|
-
class Parameter
|
3
|
-
include OasParser::RawAccessor
|
2
|
+
class Parameter < AbstractAttribute
|
4
3
|
raw_keys :name, :in, :description, :style, :enum, :schema,
|
5
4
|
:minimum, :maximum, :required
|
6
5
|
|
@@ -19,18 +18,6 @@ module OasParser
|
|
19
18
|
raw['format'] || (schema ? schema['format'] : nil)
|
20
19
|
end
|
21
20
|
|
22
|
-
def array?
|
23
|
-
type == 'array'
|
24
|
-
end
|
25
|
-
|
26
|
-
def object?
|
27
|
-
type == 'object'
|
28
|
-
end
|
29
|
-
|
30
|
-
def collection?
|
31
|
-
array? || object?
|
32
|
-
end
|
33
|
-
|
34
21
|
def items
|
35
22
|
schema['items']
|
36
23
|
end
|
@@ -43,12 +30,6 @@ module OasParser
|
|
43
30
|
raw['default'] || (schema ? schema['default'] : nil)
|
44
31
|
end
|
45
32
|
|
46
|
-
def properties
|
47
|
-
return convert_property_schema_to_properties(raw['properties']) if object?
|
48
|
-
return convert_property_schema_to_properties(items) if array?
|
49
|
-
nil
|
50
|
-
end
|
51
|
-
|
52
33
|
def convert_property_schema_to_properties(schema)
|
53
34
|
schema.map do |name, definition|
|
54
35
|
OasParser::Property.new(self, raw, name, definition)
|
data/lib/oas_parser/property.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module OasParser
|
2
|
-
class Property
|
3
|
-
include OasParser::RawAccessor
|
2
|
+
class Property < AbstractAttribute
|
4
3
|
raw_keys :name, :description, :type, :format, :enum, :minimum, :maximum,
|
5
4
|
:example, :default, :items
|
6
5
|
|
@@ -19,24 +18,6 @@ module OasParser
|
|
19
18
|
schema['required'].include? name
|
20
19
|
end
|
21
20
|
|
22
|
-
def array?
|
23
|
-
type == 'array'
|
24
|
-
end
|
25
|
-
|
26
|
-
def object?
|
27
|
-
type == 'object'
|
28
|
-
end
|
29
|
-
|
30
|
-
def collection?
|
31
|
-
array? || object?
|
32
|
-
end
|
33
|
-
|
34
|
-
def properties
|
35
|
-
return convert_property_schema_to_properties(raw['properties']) if object?
|
36
|
-
return convert_property_schema_to_properties(items) if array?
|
37
|
-
nil
|
38
|
-
end
|
39
|
-
|
40
21
|
def convert_property_schema_to_properties(schema)
|
41
22
|
schema = schema['properties'] if schema['properties']
|
42
23
|
schema.map do |name, definition|
|
data/lib/oas_parser/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oas_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Butler
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -198,6 +198,7 @@ files:
|
|
198
198
|
- bin/console
|
199
199
|
- bin/setup
|
200
200
|
- lib/oas_parser.rb
|
201
|
+
- lib/oas_parser/abstract_attribute.rb
|
201
202
|
- lib/oas_parser/callback.rb
|
202
203
|
- lib/oas_parser/definition.rb
|
203
204
|
- lib/oas_parser/endpoint.rb
|