openapi3_parser 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/CHANGELOG.md +6 -0
  4. data/README.md +5 -1
  5. data/TODO.md +1 -0
  6. data/lib/openapi3_parser.rb +13 -0
  7. data/lib/openapi3_parser/context.rb +2 -2
  8. data/lib/openapi3_parser/node_factories/array.rb +4 -2
  9. data/lib/openapi3_parser/node_factories/components.rb +4 -0
  10. data/lib/openapi3_parser/node_factories/schema.rb +15 -2
  11. data/lib/openapi3_parser/node_factories/server_variable.rb +10 -2
  12. data/lib/openapi3_parser/node_factory.rb +17 -1
  13. data/lib/openapi3_parser/node_factory/map.rb +4 -0
  14. data/lib/openapi3_parser/node_factory/object.rb +3 -5
  15. data/lib/openapi3_parser/node_factory/object/node_builder.rb +19 -8
  16. data/lib/openapi3_parser/nodes/array.rb +8 -0
  17. data/lib/openapi3_parser/nodes/callback.rb +1 -0
  18. data/lib/openapi3_parser/nodes/components.rb +12 -0
  19. data/lib/openapi3_parser/nodes/contact.rb +4 -0
  20. data/lib/openapi3_parser/nodes/discriminator.rb +3 -0
  21. data/lib/openapi3_parser/nodes/encoding.rb +6 -0
  22. data/lib/openapi3_parser/nodes/example.rb +5 -0
  23. data/lib/openapi3_parser/nodes/external_documentation.rb +3 -0
  24. data/lib/openapi3_parser/nodes/header.rb +1 -0
  25. data/lib/openapi3_parser/nodes/info.rb +7 -0
  26. data/lib/openapi3_parser/nodes/license.rb +3 -0
  27. data/lib/openapi3_parser/nodes/link.rb +7 -0
  28. data/lib/openapi3_parser/nodes/map.rb +6 -0
  29. data/lib/openapi3_parser/nodes/media_type.rb +5 -0
  30. data/lib/openapi3_parser/nodes/oauth_flow.rb +5 -0
  31. data/lib/openapi3_parser/nodes/oauth_flows.rb +5 -0
  32. data/lib/openapi3_parser/nodes/openapi.rb +11 -0
  33. data/lib/openapi3_parser/nodes/operation.rb +16 -0
  34. data/lib/openapi3_parser/nodes/parameter.rb +3 -0
  35. data/lib/openapi3_parser/nodes/parameter/parameter_like.rb +14 -0
  36. data/lib/openapi3_parser/nodes/path_item.rb +14 -0
  37. data/lib/openapi3_parser/nodes/paths.rb +1 -0
  38. data/lib/openapi3_parser/nodes/request_body.rb +4 -0
  39. data/lib/openapi3_parser/nodes/response.rb +5 -0
  40. data/lib/openapi3_parser/nodes/responses.rb +2 -0
  41. data/lib/openapi3_parser/nodes/schema.rb +38 -0
  42. data/lib/openapi3_parser/nodes/security_requirement.rb +1 -0
  43. data/lib/openapi3_parser/nodes/security_scheme.rb +9 -0
  44. data/lib/openapi3_parser/nodes/server.rb +5 -2
  45. data/lib/openapi3_parser/nodes/server_variable.rb +4 -0
  46. data/lib/openapi3_parser/nodes/tag.rb +4 -0
  47. data/lib/openapi3_parser/nodes/xml.rb +8 -2
  48. data/lib/openapi3_parser/version.rb +1 -1
  49. metadata +3 -2
@@ -4,53 +4,67 @@ require "openapi3_parser/node/object"
4
4
 
5
5
  module Openapi3Parser
6
6
  module Nodes
7
+ # @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#pathItemObject
7
8
  class PathItem
8
9
  include Node::Object
9
10
 
11
+ # @return [String, nil]
10
12
  def summary
11
13
  node_data["summary"]
12
14
  end
13
15
 
16
+ # @return [String, nil]
14
17
  def description
15
18
  node_data["description"]
16
19
  end
17
20
 
21
+ # @return [Operation, nil]
18
22
  def get
19
23
  node_data["get"]
20
24
  end
21
25
 
26
+ # @return [Operation, nil]
22
27
  def put
23
28
  node_data["put"]
24
29
  end
25
30
 
31
+ # @return [Operation, nil]
26
32
  def post
27
33
  node_data["post"]
28
34
  end
29
35
 
36
+ # @return [Operation, nil]
30
37
  def delete
31
38
  node_data["delete"]
32
39
  end
33
40
 
41
+ # @return [Operation, nil]
34
42
  def options
35
43
  node_data["options"]
36
44
  end
37
45
 
46
+ # @return [Operation, nil]
38
47
  def head
39
48
  node_data["head"]
40
49
  end
41
50
 
51
+ # @return [Operation, nil]
42
52
  def patch
43
53
  node_data["patch"]
44
54
  end
45
55
 
56
+ # @return [Operation, nil]
46
57
  def trace
47
58
  node_data["trace"]
48
59
  end
49
60
 
61
+ # @return [Nodes::Array] a collection of {Server}[./Server.html] objects
50
62
  def servers
51
63
  node_data["servers"]
52
64
  end
53
65
 
66
+ # @return [Nodes::Array] a collection of {Parameter}[./Parameter.html]
67
+ # objects
54
68
  def parameters
55
69
  node_data["parameters"]
56
70
  end
@@ -4,6 +4,7 @@ require "openapi3_parser/node/map"
4
4
 
5
5
  module Openapi3Parser
6
6
  module Nodes
7
+ # @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#pathsObject
7
8
  class Paths
8
9
  include Node::Map
9
10
  end
@@ -4,17 +4,21 @@ require "openapi3_parser/node/object"
4
4
 
5
5
  module Openapi3Parser
6
6
  module Nodes
7
+ # @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#requestBodyObject
7
8
  class RequestBody
8
9
  include Node::Object
9
10
 
11
+ # @return [String, nil]
10
12
  def description
11
13
  node_data["description"]
12
14
  end
13
15
 
16
+ # @return [Map] a map of String: {MediaType}[./MediaType.html] objects
14
17
  def content
15
18
  node_data["content"]
16
19
  end
17
20
 
21
+ # @return [Boolean]
18
22
  def required?
19
23
  node_data["required"]
20
24
  end
@@ -4,21 +4,26 @@ require "openapi3_parser/node/object"
4
4
 
5
5
  module Openapi3Parser
6
6
  module Nodes
7
+ # @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#responseObject
7
8
  class Response
8
9
  include Node::Object
9
10
 
11
+ # @return [String]
10
12
  def description
11
13
  node_data["description"]
12
14
  end
13
15
 
16
+ # @return [Map] a map of String: {Header}[./Header.html] objects
14
17
  def headers
15
18
  node_data["headers"]
16
19
  end
17
20
 
21
+ # @return [Map] a map of String: {MediaType}[./MediaType.html] objects
18
22
  def content
19
23
  node_data["content"]
20
24
  end
21
25
 
26
+ # @return [Map] a map of String: {Link}[./Link.html] objects
22
27
  def links
23
28
  node_data["links"]
24
29
  end
@@ -4,9 +4,11 @@ require "openapi3_parser/node/map"
4
4
 
5
5
  module Openapi3Parser
6
6
  module Nodes
7
+ # @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#responsesObject
7
8
  class Responses
8
9
  include Node::Map
9
10
 
11
+ # @return [Response]
10
12
  def default
11
13
  node_data["default"]
12
14
  end
@@ -4,152 +4,190 @@ require "openapi3_parser/node/object"
4
4
 
5
5
  module Openapi3Parser
6
6
  module Nodes
7
+ # @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#schemaObject
7
8
  # rubocop:disable ClassLength
8
9
  class Schema
9
10
  include Node::Object
10
11
 
12
+ # @return [String, nil]
11
13
  def title
12
14
  node_data["title"]
13
15
  end
14
16
 
17
+ # @return [Numeric, nil]
15
18
  def multiple_of
16
19
  node_data["multipleOf"]
17
20
  end
18
21
 
22
+ # @return [Integer, nil]
19
23
  def maximum
20
24
  node_data["maximum"]
21
25
  end
22
26
 
27
+ # @return [Boolean]
23
28
  def exclusive_maximum?
24
29
  node_data["exclusiveMaximum"]
25
30
  end
26
31
 
32
+ # @return [Integer, nil]
27
33
  def minimum
28
34
  node_data["minimum"]
29
35
  end
30
36
 
37
+ # @return [Boolean]
31
38
  def exclusive_minimum?
32
39
  node_data["exclusiveMinimum"]
33
40
  end
34
41
 
42
+ # @return [Integer, nil]
35
43
  def max_length
36
44
  node_data["maxLength"]
37
45
  end
38
46
 
47
+ # @return [Integer]
39
48
  def min_length
40
49
  node_data["minLength"]
41
50
  end
42
51
 
52
+ # @return [String, nil]
43
53
  def pattern
44
54
  node_data["pattern"]
45
55
  end
46
56
 
57
+ # @return [Integer, nil]
47
58
  def max_items
48
59
  node_data["maxItems"]
49
60
  end
50
61
 
62
+ # @return [Integer]
51
63
  def min_items
52
64
  node_data["minItems"]
53
65
  end
54
66
 
67
+ # @return [Boolean]
55
68
  def unique_items?
56
69
  node_data["uniqueItems"]
57
70
  end
58
71
 
72
+ # @return [Integer, nil]
59
73
  def max_properties
60
74
  node_data["maxProperties"]
61
75
  end
62
76
 
77
+ # @return [Integer]
63
78
  def min_properties
64
79
  node_data["minProperties"]
65
80
  end
66
81
 
82
+ # @return [Nodes::Array, nil] a collection of String objects or nil
67
83
  def required
68
84
  node_data["required"]
69
85
  end
70
86
 
87
+ # @return [Nodes::Array, nil] a collection of objects of no fixed type or
88
+ # nil
71
89
  def enum
72
90
  node_data["enum"]
73
91
  end
74
92
 
93
+ # @return [String, nil]
75
94
  def type
76
95
  node_data["type"]
77
96
  end
78
97
 
98
+ # @return [Nodes::Array, nil] a collection of Schema objects or nil
79
99
  def all_of
80
100
  node_data["allOf"]
81
101
  end
82
102
 
103
+ # @return [Nodes::Array, nil] a collection of Schema objects or nil
83
104
  def one_of
84
105
  node_data["oneOf"]
85
106
  end
86
107
 
108
+ # @return [Nodes::Array, nil] a collection of Schema objects or nil
87
109
  def any_of
88
110
  node_data["anyOf"]
89
111
  end
90
112
 
113
+ # @return [Schema, nil]
91
114
  def not
92
115
  node_data["not"]
93
116
  end
94
117
 
118
+ # @return [Schema, nil]
95
119
  def items
96
120
  node_data["items"]
97
121
  end
98
122
 
123
+ # @return [Map] a collection of Schema objects
99
124
  def properties
100
125
  node_data["properties"]
101
126
  end
102
127
 
128
+ # @return [Boolean]
103
129
  def additional_properties?
104
130
  node_data["additionalProperties"] != false
105
131
  end
106
132
 
133
+ # @return [Schema, nil]
107
134
  def additional_properties_schema
108
135
  properties = node_data["additionalProperties"]
109
136
  return if [true, false].include?(properties)
110
137
  properties
111
138
  end
112
139
 
140
+ # @return [String, nil]
113
141
  def description
114
142
  node_data["description"]
115
143
  end
116
144
 
145
+ # @return [String, nil]
117
146
  def format
118
147
  node_data["format"]
119
148
  end
120
149
 
150
+ # @return [Any]
121
151
  def default
122
152
  node_data["default"]
123
153
  end
124
154
 
155
+ # @return [Boolean]
125
156
  def nullable?
126
157
  node_data["nullable"]
127
158
  end
128
159
 
160
+ # @return [Discriminator, nil]
129
161
  def disciminator
130
162
  node_data["discriminator"]
131
163
  end
132
164
 
165
+ # @return [Boolean]
133
166
  def read_only?
134
167
  node_data["readOnly"]
135
168
  end
136
169
 
170
+ # @return [Boolean]
137
171
  def write_only?
138
172
  node_data["writeOnly"]
139
173
  end
140
174
 
175
+ # @return [Xml, nil]
141
176
  def xml
142
177
  node_data["xml"]
143
178
  end
144
179
 
180
+ # @return [ExternalDocumentation, nil]
145
181
  def external_docs
146
182
  node_data["externalDocs"]
147
183
  end
148
184
 
185
+ # @return [Any]
149
186
  def example
150
187
  node_data["example"]
151
188
  end
152
189
 
190
+ # @return [Boolean]
153
191
  def deprecated?
154
192
  node_data["deprecated"]
155
193
  end
@@ -4,6 +4,7 @@ require "openapi3_parser/node/map"
4
4
 
5
5
  module Openapi3Parser
6
6
  module Nodes
7
+ # @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#securityRequirementObject
7
8
  class SecurityRequirement
8
9
  include Node::Map
9
10
  end
@@ -5,37 +5,46 @@ require "openapi3_parser/nodes/oauth_flows"
5
5
 
6
6
  module Openapi3Parser
7
7
  module Nodes
8
+ # @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#securitySchemeObject
8
9
  class SecurityScheme
9
10
  include Node::Object
10
11
 
12
+ # @return [String, nil]
11
13
  def type
12
14
  node_data["type"]
13
15
  end
14
16
 
17
+ # @return [String, nil]
15
18
  def description
16
19
  node_data["description"]
17
20
  end
18
21
 
22
+ # @return [String, nil]
19
23
  def name
20
24
  node_data["name"]
21
25
  end
22
26
 
27
+ # @return [String, nil]
23
28
  def in
24
29
  node_data["in"]
25
30
  end
26
31
 
32
+ # @return [String, nil]
27
33
  def scheme
28
34
  node_data["scheme"]
29
35
  end
30
36
 
37
+ # @return [String, nil]
31
38
  def bearer_format
32
39
  node_data["bearerFormat"]
33
40
  end
34
41
 
42
+ # @return [OauthFlows, nil]
35
43
  def flows
36
44
  node_data["flows"]
37
45
  end
38
46
 
47
+ # @return [String, nil]
39
48
  def open_id_connect_url
40
49
  node_data["openIdConnectUrl"]
41
50
  end
@@ -4,19 +4,22 @@ require "openapi3_parser/node/object"
4
4
 
5
5
  module Openapi3Parser
6
6
  module Nodes
7
+ # @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#serverObject
7
8
  class Server
8
9
  include Node::Object
9
10
 
10
- # @TODO there's scope for an interpolated_url method which can use the
11
- # values from variables
11
+ # @return [String]
12
12
  def url
13
13
  node_data["url"]
14
14
  end
15
15
 
16
+ # @return [String, nil]
16
17
  def description
17
18
  node_data["description"]
18
19
  end
19
20
 
21
+ # @return [Map] a map of String: {ServerVariable}[./ServerVariable.html]
22
+ # objects
20
23
  def variables
21
24
  node_data["variables"]
22
25
  end
@@ -4,17 +4,21 @@ require "openapi3_parser/node/object"
4
4
 
5
5
  module Openapi3Parser
6
6
  module Nodes
7
+ # @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#serverVariableObject
7
8
  class ServerVariable
8
9
  include Node::Object
9
10
 
11
+ # @return [Nodes::Array, nil] a collection of String objects or nil
10
12
  def enum
11
13
  node_data["enum"]
12
14
  end
13
15
 
16
+ # @return [String]
14
17
  def default
15
18
  node_data["default"]
16
19
  end
17
20
 
21
+ # @return [String, nil]
18
22
  def description
19
23
  node_data["description"]
20
24
  end
@@ -4,17 +4,21 @@ require "openapi3_parser/node/object"
4
4
 
5
5
  module Openapi3Parser
6
6
  module Nodes
7
+ # @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#tagObject
7
8
  class Tag
8
9
  include Node::Object
9
10
 
11
+ # @return [String]
10
12
  def name
11
13
  node_data["name"]
12
14
  end
13
15
 
16
+ # @return [String, nil]
14
17
  def description
15
18
  node_data["description"]
16
19
  end
17
20
 
21
+ # @return [ExternalDocumentation, nil]
18
22
  def external_docs
19
23
  node_data["externalDocs"]
20
24
  end