openapi3_parser 0.1.0 → 0.2.0
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/.gitignore +3 -0
- data/CHANGELOG.md +6 -0
- data/README.md +5 -1
- data/TODO.md +1 -0
- data/lib/openapi3_parser.rb +13 -0
- data/lib/openapi3_parser/context.rb +2 -2
- data/lib/openapi3_parser/node_factories/array.rb +4 -2
- data/lib/openapi3_parser/node_factories/components.rb +4 -0
- data/lib/openapi3_parser/node_factories/schema.rb +15 -2
- data/lib/openapi3_parser/node_factories/server_variable.rb +10 -2
- data/lib/openapi3_parser/node_factory.rb +17 -1
- data/lib/openapi3_parser/node_factory/map.rb +4 -0
- data/lib/openapi3_parser/node_factory/object.rb +3 -5
- data/lib/openapi3_parser/node_factory/object/node_builder.rb +19 -8
- data/lib/openapi3_parser/nodes/array.rb +8 -0
- data/lib/openapi3_parser/nodes/callback.rb +1 -0
- data/lib/openapi3_parser/nodes/components.rb +12 -0
- data/lib/openapi3_parser/nodes/contact.rb +4 -0
- data/lib/openapi3_parser/nodes/discriminator.rb +3 -0
- data/lib/openapi3_parser/nodes/encoding.rb +6 -0
- data/lib/openapi3_parser/nodes/example.rb +5 -0
- data/lib/openapi3_parser/nodes/external_documentation.rb +3 -0
- data/lib/openapi3_parser/nodes/header.rb +1 -0
- data/lib/openapi3_parser/nodes/info.rb +7 -0
- data/lib/openapi3_parser/nodes/license.rb +3 -0
- data/lib/openapi3_parser/nodes/link.rb +7 -0
- data/lib/openapi3_parser/nodes/map.rb +6 -0
- data/lib/openapi3_parser/nodes/media_type.rb +5 -0
- data/lib/openapi3_parser/nodes/oauth_flow.rb +5 -0
- data/lib/openapi3_parser/nodes/oauth_flows.rb +5 -0
- data/lib/openapi3_parser/nodes/openapi.rb +11 -0
- data/lib/openapi3_parser/nodes/operation.rb +16 -0
- data/lib/openapi3_parser/nodes/parameter.rb +3 -0
- data/lib/openapi3_parser/nodes/parameter/parameter_like.rb +14 -0
- data/lib/openapi3_parser/nodes/path_item.rb +14 -0
- data/lib/openapi3_parser/nodes/paths.rb +1 -0
- data/lib/openapi3_parser/nodes/request_body.rb +4 -0
- data/lib/openapi3_parser/nodes/response.rb +5 -0
- data/lib/openapi3_parser/nodes/responses.rb +2 -0
- data/lib/openapi3_parser/nodes/schema.rb +38 -0
- data/lib/openapi3_parser/nodes/security_requirement.rb +1 -0
- data/lib/openapi3_parser/nodes/security_scheme.rb +9 -0
- data/lib/openapi3_parser/nodes/server.rb +5 -2
- data/lib/openapi3_parser/nodes/server_variable.rb +4 -0
- data/lib/openapi3_parser/nodes/tag.rb +4 -0
- data/lib/openapi3_parser/nodes/xml.rb +8 -2
- data/lib/openapi3_parser/version.rb +1 -1
- metadata +3 -2
@@ -4,13 +4,16 @@ 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#discriminatorObject
|
7
8
|
class Discriminator
|
8
9
|
include Node::Object
|
9
10
|
|
11
|
+
# @return [String]
|
10
12
|
def property_name
|
11
13
|
node_data["propertyName"]
|
12
14
|
end
|
13
15
|
|
16
|
+
# @return [Map] a map of String: String objects
|
14
17
|
def mapping
|
15
18
|
node_data["mapping"]
|
16
19
|
end
|
@@ -4,25 +4,31 @@ 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#encodingObject
|
7
8
|
class Encoding
|
8
9
|
include Node::Object
|
9
10
|
|
11
|
+
# @return [String, nil]
|
10
12
|
def content_type
|
11
13
|
node_data["contentType"]
|
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 [String, nil]
|
18
22
|
def style
|
19
23
|
node_data["style"]
|
20
24
|
end
|
21
25
|
|
26
|
+
# @return [Boolean]
|
22
27
|
def explode?
|
23
28
|
node_data["explode"]
|
24
29
|
end
|
25
30
|
|
31
|
+
# @return [Boolean]
|
26
32
|
def allow_reserved?
|
27
33
|
node_data["allowReserved"]
|
28
34
|
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#exampleObject
|
7
8
|
class Example
|
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 [Object]
|
18
22
|
def value
|
19
23
|
node_data["value"]
|
20
24
|
end
|
21
25
|
|
26
|
+
# @return [String, nil]
|
22
27
|
def external_value
|
23
28
|
node_data["externalValue"]
|
24
29
|
end
|
@@ -4,13 +4,16 @@ 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#externalDocumentationObject
|
7
8
|
class ExternalDocumentation
|
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 [String]
|
14
17
|
def url
|
15
18
|
node_data["url"]
|
16
19
|
end
|
@@ -5,6 +5,7 @@ require "openapi3_parser/nodes/parameter/parameter_like"
|
|
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#headerObject
|
8
9
|
class Header
|
9
10
|
include Node::Object
|
10
11
|
include Parameter::ParameterLike
|
@@ -4,29 +4,36 @@ 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#infoObject
|
7
8
|
class Info
|
8
9
|
include Node::Object
|
9
10
|
|
11
|
+
# @return [String]
|
10
12
|
def title
|
11
13
|
node_data["title"]
|
12
14
|
end
|
13
15
|
|
16
|
+
# @return [String, null]
|
14
17
|
def description
|
15
18
|
node_data["description"]
|
16
19
|
end
|
17
20
|
|
21
|
+
# @return [String, null]
|
18
22
|
def terms_of_service
|
19
23
|
node_data["termsOfService"]
|
20
24
|
end
|
21
25
|
|
26
|
+
# @return [Contact, nil]
|
22
27
|
def contact
|
23
28
|
node_data["contact"]
|
24
29
|
end
|
25
30
|
|
31
|
+
# @return [License, nil]
|
26
32
|
def license
|
27
33
|
node_data["license"]
|
28
34
|
end
|
29
35
|
|
36
|
+
# @return [String]
|
30
37
|
def version
|
31
38
|
node_data["version"]
|
32
39
|
end
|
@@ -4,13 +4,16 @@ 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#licenseObject
|
7
8
|
class License
|
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 url
|
15
18
|
node_data["url"]
|
16
19
|
end
|
@@ -4,29 +4,36 @@ 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#linkObject
|
7
8
|
class Link
|
8
9
|
include Node::Object
|
9
10
|
|
11
|
+
# @return [String, nil]
|
10
12
|
def operation_ref
|
11
13
|
node_data["operationRef"]
|
12
14
|
end
|
13
15
|
|
16
|
+
# @return [String, nil]
|
14
17
|
def operation_id
|
15
18
|
node_data["operationId"]
|
16
19
|
end
|
17
20
|
|
21
|
+
# @return [Map] a map of String: {Parameter}[./Parameter.html] objects
|
18
22
|
def parameters
|
19
23
|
node_data["parameters"]
|
20
24
|
end
|
21
25
|
|
26
|
+
# @return [Any]
|
22
27
|
def request_body
|
23
28
|
node_data["requestBody"]
|
24
29
|
end
|
25
30
|
|
31
|
+
# @return [String, nil]
|
26
32
|
def description
|
27
33
|
node_data["description"]
|
28
34
|
end
|
29
35
|
|
36
|
+
# @return [Server, nil]
|
30
37
|
def server
|
31
38
|
node_data["server"]
|
32
39
|
end
|
@@ -4,6 +4,12 @@ require "openapi3_parser/node/map"
|
|
4
4
|
|
5
5
|
module Openapi3Parser
|
6
6
|
module Nodes
|
7
|
+
# A map within a OpenAPI document.
|
8
|
+
# Very similar to a ruby hash, however this is read only and knows
|
9
|
+
# the context of where it sits in an OpenAPI document
|
10
|
+
#
|
11
|
+
# The contents of the data will be dependent on where this document is in
|
12
|
+
# the document hierachy.
|
7
13
|
class Map
|
8
14
|
include Node::Map
|
9
15
|
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#mediaTypeObject
|
7
8
|
class MediaType
|
8
9
|
include Node::Object
|
9
10
|
|
11
|
+
# @return [Schema, nil]
|
10
12
|
def schema
|
11
13
|
node_data["schema"]
|
12
14
|
end
|
13
15
|
|
16
|
+
# @return [Any]
|
14
17
|
def example
|
15
18
|
node_data["example"]
|
16
19
|
end
|
17
20
|
|
21
|
+
# @return [Map] a map of String: {Example}[./Example.html] objects
|
18
22
|
def examples
|
19
23
|
node_data["examples"]
|
20
24
|
end
|
21
25
|
|
26
|
+
# @return [Map] a map of String: {Encoding}[./Encoding.html] objects
|
22
27
|
def encoding
|
23
28
|
node_data["encoding"]
|
24
29
|
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#oauthFlowObject
|
7
8
|
class OauthFlow
|
8
9
|
include Node::Object
|
9
10
|
|
11
|
+
# @return [String, nil]
|
10
12
|
def authorization_url
|
11
13
|
node_data["authorizationUrl"]
|
12
14
|
end
|
13
15
|
|
16
|
+
# @return [String, nil]
|
14
17
|
def token_url
|
15
18
|
node_data["tokenUrl"]
|
16
19
|
end
|
17
20
|
|
21
|
+
# @return [String, nil]
|
18
22
|
def refresh_url
|
19
23
|
node_data["refreshUrl"]
|
20
24
|
end
|
21
25
|
|
26
|
+
# @return [Map] a map of String: String objects
|
22
27
|
def scopes
|
23
28
|
node_data["scopes"]
|
24
29
|
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#oauthFlowsObject
|
7
8
|
class OauthFlows
|
8
9
|
include Node::Object
|
9
10
|
|
11
|
+
# @return [OauthFlow, nil]
|
10
12
|
def implicit
|
11
13
|
node_data["implicit"]
|
12
14
|
end
|
13
15
|
|
16
|
+
# @return [OauthFlow, nil]
|
14
17
|
def password
|
15
18
|
node_data["password"]
|
16
19
|
end
|
17
20
|
|
21
|
+
# @return [OauthFlow, nil]
|
18
22
|
def client_credentials
|
19
23
|
node_data["clientCredentials"]
|
20
24
|
end
|
21
25
|
|
26
|
+
# @return [OauthFlow, nil]
|
22
27
|
def authorization_code
|
23
28
|
node_data["authorizationCode"]
|
24
29
|
end
|
@@ -5,37 +5,48 @@ require "openapi3_parser/nodes/components"
|
|
5
5
|
|
6
6
|
module Openapi3Parser
|
7
7
|
module Nodes
|
8
|
+
# OpenAPI Root Object
|
9
|
+
# @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#oasObject
|
8
10
|
class Openapi
|
9
11
|
include Node::Object
|
10
12
|
|
13
|
+
# @return [String]
|
11
14
|
def openapi
|
12
15
|
node_data["openapi"]
|
13
16
|
end
|
14
17
|
|
18
|
+
# @return [Info]
|
15
19
|
def info
|
16
20
|
node_data["info"]
|
17
21
|
end
|
18
22
|
|
23
|
+
# @return [Nodes::Array] A collection of {Server}[./Server.html] objects
|
19
24
|
def servers
|
20
25
|
node_data["servers"]
|
21
26
|
end
|
22
27
|
|
28
|
+
# @return [Paths]
|
23
29
|
def paths
|
24
30
|
node_data["paths"]
|
25
31
|
end
|
26
32
|
|
33
|
+
# @return [Components]
|
27
34
|
def components
|
28
35
|
node_data["components"]
|
29
36
|
end
|
30
37
|
|
38
|
+
# @return [Nodes::Array] a collection of
|
39
|
+
# {SecurityRequirement}[./SecurityRequirement.html] objects
|
31
40
|
def security
|
32
41
|
node_data["security"]
|
33
42
|
end
|
34
43
|
|
44
|
+
# @return [Nodes::Array] A collection of {Tag}[./Tag.html] objects
|
35
45
|
def tags
|
36
46
|
node_data["tags"]
|
37
47
|
end
|
38
48
|
|
49
|
+
# @return [ExternalDocumentation]
|
39
50
|
def external_docs
|
40
51
|
node_data["externalDocs"]
|
41
52
|
end
|
@@ -4,53 +4,69 @@ 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#operationObject
|
7
8
|
class Operation
|
8
9
|
include Node::Object
|
9
10
|
|
11
|
+
# @return [Nodes::Array] a collection of String objects
|
10
12
|
def tags
|
11
13
|
node_data["tags"]
|
12
14
|
end
|
13
15
|
|
16
|
+
# @return [String, nil]
|
14
17
|
def summary
|
15
18
|
node_data["summary"]
|
16
19
|
end
|
17
20
|
|
21
|
+
# @return [String, nil]
|
18
22
|
def description
|
19
23
|
node_data["description"]
|
20
24
|
end
|
21
25
|
|
26
|
+
# @return [ExternalDocumentation, nil]
|
22
27
|
def external_docs
|
23
28
|
node_data["externalDocs"]
|
24
29
|
end
|
25
30
|
|
31
|
+
# @return [String, nil]
|
26
32
|
def operation_id
|
27
33
|
node_data["operationId"]
|
28
34
|
end
|
29
35
|
|
36
|
+
# @return [Nodes::Array] a collection of {Parameter}[./Parameter.html]
|
37
|
+
# objects
|
30
38
|
def parameters
|
31
39
|
node_data["parameters"]
|
32
40
|
end
|
33
41
|
|
42
|
+
# @return [RequestBody, nil]
|
34
43
|
def request_body
|
35
44
|
node_data["requestBody"]
|
36
45
|
end
|
37
46
|
|
47
|
+
# @return [Responses]
|
38
48
|
def responses
|
39
49
|
node_data["responses"]
|
40
50
|
end
|
41
51
|
|
52
|
+
# @return [Map] a collection of String: {Callback}[./Callback.html]
|
53
|
+
# objects
|
42
54
|
def callbacks
|
43
55
|
node_data["callbacks"]
|
44
56
|
end
|
45
57
|
|
58
|
+
# @return [Boolean]
|
46
59
|
def deprecated?
|
47
60
|
node_data["deprecated"]
|
48
61
|
end
|
49
62
|
|
63
|
+
# @return [Nodes::Array] a collection of
|
64
|
+
# {SecurityRequirement}[./SecurityRequirement.html] objects
|
50
65
|
def security
|
51
66
|
node_data["security"]
|
52
67
|
end
|
53
68
|
|
69
|
+
# @return [Nodes::Array] a collection of {Server}[./Server.html] objects
|
54
70
|
def servers
|
55
71
|
node_data["servers"]
|
56
72
|
end
|
@@ -5,14 +5,17 @@ require "openapi3_parser/nodes/parameter/parameter_like"
|
|
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#parameterObject
|
8
9
|
class Parameter
|
9
10
|
include Node::Object
|
10
11
|
include ParameterLike
|
11
12
|
|
13
|
+
# @return [String]
|
12
14
|
def name
|
13
15
|
node_data["name"]
|
14
16
|
end
|
15
17
|
|
18
|
+
# @return [String]
|
16
19
|
def in
|
17
20
|
node_data["in"]
|
18
21
|
end
|
@@ -3,47 +3,61 @@
|
|
3
3
|
module Openapi3Parser
|
4
4
|
module Nodes
|
5
5
|
class Parameter
|
6
|
+
# This contains methods that are shared between nodes that act like a
|
7
|
+
# Parameter, at the time of writing this was {Header}[../Header.html]
|
8
|
+
# and {Parameter}[../Paramater.html]
|
6
9
|
module ParameterLike
|
10
|
+
# @return [String]
|
7
11
|
def description
|
8
12
|
node_data["description"]
|
9
13
|
end
|
10
14
|
|
15
|
+
# @return [Boolean]
|
11
16
|
def required?
|
12
17
|
node_data["required"]
|
13
18
|
end
|
14
19
|
|
20
|
+
# @return [Boolean]
|
15
21
|
def deprecated?
|
16
22
|
node_data["deprecated"]
|
17
23
|
end
|
18
24
|
|
25
|
+
# @return [Boolean]
|
19
26
|
def allow_empty_value?
|
20
27
|
node_data["allowEmptyValue"]
|
21
28
|
end
|
22
29
|
|
30
|
+
# @return [String, nil]
|
23
31
|
def style
|
24
32
|
node_data["style"]
|
25
33
|
end
|
26
34
|
|
35
|
+
# @return [Boolean]
|
27
36
|
def explode?
|
28
37
|
node_data["explode"]
|
29
38
|
end
|
30
39
|
|
40
|
+
# @return [Boolean]
|
31
41
|
def allow_reserved?
|
32
42
|
node_data["allowReserved"]
|
33
43
|
end
|
34
44
|
|
45
|
+
# @return [Schema, nil]
|
35
46
|
def schema
|
36
47
|
node_data["schema"]
|
37
48
|
end
|
38
49
|
|
50
|
+
# @return [Any]
|
39
51
|
def example
|
40
52
|
node_data["example"]
|
41
53
|
end
|
42
54
|
|
55
|
+
# @return [Map] a map of String: {Example}[../Example.html] objects
|
43
56
|
def examples
|
44
57
|
node_data["examples"]
|
45
58
|
end
|
46
59
|
|
60
|
+
# @return [Map] a map of String: {MediaType}[../MediaType.html] objects
|
47
61
|
def content
|
48
62
|
node_data["content"]
|
49
63
|
end
|