openapi3_parser 0.3.0 → 0.4.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/.rubocop.yml +4 -0
- data/.travis.yml +3 -5
- data/CHANGELOG.md +7 -0
- data/README.md +2 -2
- data/TODO.md +9 -2
- data/lib/openapi3_parser/context/pointer.rb +2 -0
- data/lib/openapi3_parser/document.rb +54 -18
- data/lib/openapi3_parser/markdown.rb +15 -0
- data/lib/openapi3_parser/{nodes → node}/array.rb +1 -1
- data/lib/openapi3_parser/{nodes → node}/callback.rb +2 -4
- data/lib/openapi3_parser/{nodes → node}/components.rb +2 -4
- data/lib/openapi3_parser/{nodes → node}/contact.rb +2 -4
- data/lib/openapi3_parser/{nodes → node}/discriminator.rb +2 -4
- data/lib/openapi3_parser/{nodes → node}/encoding.rb +2 -4
- data/lib/openapi3_parser/{nodes → node}/example.rb +7 -4
- data/lib/openapi3_parser/{nodes → node}/external_documentation.rb +7 -4
- data/lib/openapi3_parser/{nodes → node}/header.rb +4 -5
- data/lib/openapi3_parser/{nodes → node}/info.rb +9 -6
- data/lib/openapi3_parser/{nodes → node}/license.rb +2 -4
- data/lib/openapi3_parser/{nodes → node}/link.rb +7 -4
- data/lib/openapi3_parser/node/map.rb +1 -1
- data/lib/openapi3_parser/{nodes → node}/media_type.rb +2 -4
- data/lib/openapi3_parser/{nodes → node}/oauth_flow.rb +2 -4
- data/lib/openapi3_parser/{nodes → node}/oauth_flows.rb +2 -4
- data/lib/openapi3_parser/node/object.rb +11 -1
- data/lib/openapi3_parser/{nodes → node}/openapi.rb +6 -8
- data/lib/openapi3_parser/{nodes → node}/operation.rb +11 -8
- data/lib/openapi3_parser/{nodes → node}/parameter.rb +3 -4
- data/lib/openapi3_parser/node/parameter_like.rb +70 -0
- data/lib/openapi3_parser/{nodes → node}/path_item.rb +9 -6
- data/lib/openapi3_parser/{nodes → node}/paths.rb +2 -4
- data/lib/openapi3_parser/{nodes → node}/request_body.rb +7 -4
- data/lib/openapi3_parser/{nodes → node}/response.rb +7 -4
- data/lib/openapi3_parser/{nodes → node}/responses.rb +2 -4
- data/lib/openapi3_parser/{nodes → node}/schema.rb +12 -9
- data/lib/openapi3_parser/{nodes → node}/security_requirement.rb +2 -4
- data/lib/openapi3_parser/{nodes → node}/security_scheme.rb +7 -5
- data/lib/openapi3_parser/{nodes → node}/server.rb +7 -4
- data/lib/openapi3_parser/{nodes → node}/server_variable.rb +8 -5
- data/lib/openapi3_parser/{nodes → node}/tag.rb +7 -4
- data/lib/openapi3_parser/{nodes → node}/xml.rb +2 -4
- data/lib/openapi3_parser/node_factories/array.rb +10 -4
- data/lib/openapi3_parser/node_factories/callback.rb +2 -2
- data/lib/openapi3_parser/node_factories/components.rb +5 -3
- data/lib/openapi3_parser/node_factories/contact.rb +10 -4
- data/lib/openapi3_parser/node_factories/discriminator.rb +2 -2
- data/lib/openapi3_parser/node_factories/encoding.rb +7 -3
- data/lib/openapi3_parser/node_factories/example.rb +8 -3
- data/lib/openapi3_parser/node_factories/external_documentation.rb +7 -3
- data/lib/openapi3_parser/node_factories/header.rb +2 -2
- data/lib/openapi3_parser/node_factories/info.rb +6 -3
- data/lib/openapi3_parser/node_factories/license.rb +6 -3
- data/lib/openapi3_parser/node_factories/link.rb +4 -2
- data/lib/openapi3_parser/node_factories/map.rb +12 -4
- data/lib/openapi3_parser/node_factories/media_type.rb +36 -5
- data/lib/openapi3_parser/node_factories/oauth_flow.rb +2 -2
- data/lib/openapi3_parser/node_factories/oauth_flows.rb +2 -2
- data/lib/openapi3_parser/node_factories/openapi.rb +13 -3
- data/lib/openapi3_parser/node_factories/operation.rb +11 -3
- data/lib/openapi3_parser/node_factories/parameter.rb +28 -3
- data/lib/openapi3_parser/node_factories/parameter/parameter_like.rb +9 -5
- data/lib/openapi3_parser/node_factories/path_item.rb +26 -7
- data/lib/openapi3_parser/node_factories/paths.rb +51 -2
- data/lib/openapi3_parser/node_factories/reference.rb +4 -0
- data/lib/openapi3_parser/node_factories/request_body.rb +32 -3
- data/lib/openapi3_parser/node_factories/response.rb +24 -4
- data/lib/openapi3_parser/node_factories/responses.rb +28 -2
- data/lib/openapi3_parser/node_factories/schema.rb +17 -3
- data/lib/openapi3_parser/node_factories/security_requirement.rb +2 -2
- data/lib/openapi3_parser/node_factories/security_scheme.rb +2 -2
- data/lib/openapi3_parser/node_factories/server.rb +2 -2
- data/lib/openapi3_parser/node_factories/server_variable.rb +2 -2
- data/lib/openapi3_parser/node_factories/tag.rb +2 -2
- data/lib/openapi3_parser/node_factories/xml.rb +6 -3
- data/lib/openapi3_parser/node_factory.rb +10 -4
- data/lib/openapi3_parser/node_factory/fields/reference.rb +4 -0
- data/lib/openapi3_parser/node_factory/map.rb +10 -0
- data/lib/openapi3_parser/node_factory/object.rb +29 -0
- data/lib/openapi3_parser/node_factory/object/validator.rb +69 -6
- data/lib/openapi3_parser/source/reference.rb +2 -0
- data/lib/openapi3_parser/source/reference_resolver.rb +5 -1
- data/lib/openapi3_parser/validators/absolute_uri.rb +14 -0
- data/lib/openapi3_parser/validators/component_keys.rb +17 -0
- data/lib/openapi3_parser/validators/duplicate_parameters.rb +30 -0
- data/lib/openapi3_parser/validators/email.rb +23 -0
- data/lib/openapi3_parser/validators/media_type.rb +20 -0
- data/lib/openapi3_parser/validators/url.rb +18 -0
- data/lib/openapi3_parser/version.rb +1 -1
- data/openapi3_parser.gemspec +5 -2
- metadata +70 -36
- data/lib/openapi3_parser/nodes/map.rb +0 -17
- data/lib/openapi3_parser/nodes/parameter/parameter_like.rb +0 -67
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
require "openapi3_parser/node/map"
|
|
4
4
|
|
|
5
5
|
module Openapi3Parser
|
|
6
|
-
module
|
|
6
|
+
module Node
|
|
7
7
|
# @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#securityRequirementObject
|
|
8
|
-
class SecurityRequirement
|
|
9
|
-
include Node::Map
|
|
10
|
-
end
|
|
8
|
+
class SecurityRequirement < Node::Map; end
|
|
11
9
|
end
|
|
12
10
|
end
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "openapi3_parser/node/object"
|
|
4
|
-
require "openapi3_parser/nodes/oauth_flows"
|
|
5
4
|
|
|
6
5
|
module Openapi3Parser
|
|
7
|
-
module
|
|
6
|
+
module Node
|
|
8
7
|
# @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#securitySchemeObject
|
|
9
|
-
class SecurityScheme
|
|
10
|
-
include Node::Object
|
|
11
|
-
|
|
8
|
+
class SecurityScheme < Node::Object
|
|
12
9
|
# @return [String, nil]
|
|
13
10
|
def type
|
|
14
11
|
node_data["type"]
|
|
@@ -19,6 +16,11 @@ module Openapi3Parser
|
|
|
19
16
|
node_data["description"]
|
|
20
17
|
end
|
|
21
18
|
|
|
19
|
+
# @return [String, nil]
|
|
20
|
+
def description_html
|
|
21
|
+
render_markdown(description)
|
|
22
|
+
end
|
|
23
|
+
|
|
22
24
|
# @return [String, nil]
|
|
23
25
|
def name
|
|
24
26
|
node_data["name"]
|
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
require "openapi3_parser/node/object"
|
|
4
4
|
|
|
5
5
|
module Openapi3Parser
|
|
6
|
-
module
|
|
6
|
+
module Node
|
|
7
7
|
# @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#serverObject
|
|
8
|
-
class Server
|
|
9
|
-
include Node::Object
|
|
10
|
-
|
|
8
|
+
class Server < Node::Object
|
|
11
9
|
# @return [String]
|
|
12
10
|
def url
|
|
13
11
|
node_data["url"]
|
|
@@ -18,6 +16,11 @@ module Openapi3Parser
|
|
|
18
16
|
node_data["description"]
|
|
19
17
|
end
|
|
20
18
|
|
|
19
|
+
# @return [String, nil]
|
|
20
|
+
def description_html
|
|
21
|
+
render_markdown(description)
|
|
22
|
+
end
|
|
23
|
+
|
|
21
24
|
# @return [Map<String, ServerVariable>]
|
|
22
25
|
def variables
|
|
23
26
|
node_data["variables"]
|
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
require "openapi3_parser/node/object"
|
|
4
4
|
|
|
5
5
|
module Openapi3Parser
|
|
6
|
-
module
|
|
6
|
+
module Node
|
|
7
7
|
# @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#serverVariableObject
|
|
8
|
-
class ServerVariable
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
# @return [Nodes::Array<String>, nil]
|
|
8
|
+
class ServerVariable < Node::Object
|
|
9
|
+
# @return [Node::Array<String>, nil]
|
|
12
10
|
def enum
|
|
13
11
|
node_data["enum"]
|
|
14
12
|
end
|
|
@@ -22,6 +20,11 @@ module Openapi3Parser
|
|
|
22
20
|
def description
|
|
23
21
|
node_data["description"]
|
|
24
22
|
end
|
|
23
|
+
|
|
24
|
+
# @return [String, nil]
|
|
25
|
+
def description_html
|
|
26
|
+
render_markdown(description)
|
|
27
|
+
end
|
|
25
28
|
end
|
|
26
29
|
end
|
|
27
30
|
end
|
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
require "openapi3_parser/node/object"
|
|
4
4
|
|
|
5
5
|
module Openapi3Parser
|
|
6
|
-
module
|
|
6
|
+
module Node
|
|
7
7
|
# @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#tagObject
|
|
8
|
-
class Tag
|
|
9
|
-
include Node::Object
|
|
10
|
-
|
|
8
|
+
class Tag < Node::Object
|
|
11
9
|
# @return [String]
|
|
12
10
|
def name
|
|
13
11
|
node_data["name"]
|
|
@@ -18,6 +16,11 @@ module Openapi3Parser
|
|
|
18
16
|
node_data["description"]
|
|
19
17
|
end
|
|
20
18
|
|
|
19
|
+
# @return [String, nil]
|
|
20
|
+
def description_html
|
|
21
|
+
render_markdown(description)
|
|
22
|
+
end
|
|
23
|
+
|
|
21
24
|
# @return [ExternalDocumentation, nil]
|
|
22
25
|
def external_docs
|
|
23
26
|
node_data["externalDocs"]
|
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
require "openapi3_parser/node/object"
|
|
4
4
|
|
|
5
5
|
module Openapi3Parser
|
|
6
|
-
module
|
|
6
|
+
module Node
|
|
7
7
|
# @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#xmlObject
|
|
8
|
-
class Xml
|
|
9
|
-
include Node::Object
|
|
10
|
-
|
|
8
|
+
class Xml < Node::Object
|
|
11
9
|
# @return [String, nil]
|
|
12
10
|
def name
|
|
13
11
|
node_data["name"]
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require "openapi3_parser/context"
|
|
4
4
|
require "openapi3_parser/error"
|
|
5
5
|
require "openapi3_parser/node_factory"
|
|
6
|
-
require "openapi3_parser/
|
|
6
|
+
require "openapi3_parser/node/array"
|
|
7
7
|
require "openapi3_parser/validation/error"
|
|
8
8
|
require "openapi3_parser/validation/error_collection"
|
|
9
9
|
|
|
@@ -42,8 +42,8 @@ module Openapi3Parser
|
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
def validate(input,
|
|
46
|
-
given_validate&.call(input,
|
|
45
|
+
def validate(input, _context)
|
|
46
|
+
given_validate&.call(input, self)
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def validate_input
|
|
@@ -64,7 +64,13 @@ module Openapi3Parser
|
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
def build_array(data, context)
|
|
67
|
-
|
|
67
|
+
Node::Array.new(data, context)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def build_resolved_input
|
|
71
|
+
processed_input.map do |value|
|
|
72
|
+
value.respond_to?(:resolved_input) ? value.resolved_input : value
|
|
73
|
+
end
|
|
68
74
|
end
|
|
69
75
|
|
|
70
76
|
def value_factory?
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "openapi3_parser/node_factory/map"
|
|
4
4
|
require "openapi3_parser/node_factories/path_item"
|
|
5
|
-
require "openapi3_parser/
|
|
5
|
+
require "openapi3_parser/node/callback"
|
|
6
6
|
|
|
7
7
|
module Openapi3Parser
|
|
8
8
|
module NodeFactories
|
|
@@ -20,7 +20,7 @@ module Openapi3Parser
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def build_map(data, context)
|
|
23
|
-
|
|
23
|
+
Node::Callback.new(data, context)
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "openapi3_parser/
|
|
3
|
+
require "openapi3_parser/node/components"
|
|
4
4
|
require "openapi3_parser/node_factory/object"
|
|
5
5
|
require "openapi3_parser/node_factory/optional_reference"
|
|
6
6
|
require "openapi3_parser/node_factories/map"
|
|
@@ -13,6 +13,7 @@ require "openapi3_parser/node_factories/header"
|
|
|
13
13
|
require "openapi3_parser/node_factories/security_scheme"
|
|
14
14
|
require "openapi3_parser/node_factories/link"
|
|
15
15
|
require "openapi3_parser/node_factories/callback"
|
|
16
|
+
require "openapi3_parser/validators/component_keys"
|
|
16
17
|
|
|
17
18
|
module Openapi3Parser
|
|
18
19
|
module NodeFactories
|
|
@@ -33,7 +34,7 @@ module Openapi3Parser
|
|
|
33
34
|
private
|
|
34
35
|
|
|
35
36
|
def build_object(data, context)
|
|
36
|
-
|
|
37
|
+
Node::Components.new(data, context)
|
|
37
38
|
end
|
|
38
39
|
|
|
39
40
|
def schemas_factory(context)
|
|
@@ -75,7 +76,8 @@ module Openapi3Parser
|
|
|
75
76
|
def referenceable_map_factory(context, factory)
|
|
76
77
|
NodeFactories::Map.new(
|
|
77
78
|
context,
|
|
78
|
-
value_factory: NodeFactory::OptionalReference.new(factory)
|
|
79
|
+
value_factory: NodeFactory::OptionalReference.new(factory),
|
|
80
|
+
validate: ->(input, _) { Validators::ComponentKeys.call(input) }
|
|
79
81
|
)
|
|
80
82
|
end
|
|
81
83
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "openapi3_parser/
|
|
3
|
+
require "openapi3_parser/node/contact"
|
|
4
4
|
require "openapi3_parser/node_factory/object"
|
|
5
|
+
require "openapi3_parser/validators/url"
|
|
6
|
+
require "openapi3_parser/validators/email"
|
|
5
7
|
|
|
6
8
|
module Openapi3Parser
|
|
7
9
|
module NodeFactories
|
|
@@ -11,13 +13,17 @@ module Openapi3Parser
|
|
|
11
13
|
allow_extensions
|
|
12
14
|
|
|
13
15
|
field "name", input_type: String
|
|
14
|
-
field "url",
|
|
15
|
-
|
|
16
|
+
field "url",
|
|
17
|
+
input_type: String,
|
|
18
|
+
validate: ->(input) { Validators::Url.call(input) }
|
|
19
|
+
field "email",
|
|
20
|
+
input_type: String,
|
|
21
|
+
validate: ->(input) { Validators::Email.call(input) }
|
|
16
22
|
|
|
17
23
|
private
|
|
18
24
|
|
|
19
25
|
def build_object(data, context)
|
|
20
|
-
|
|
26
|
+
Node::Contact.new(data, context)
|
|
21
27
|
end
|
|
22
28
|
end
|
|
23
29
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "openapi3_parser/
|
|
3
|
+
require "openapi3_parser/node/discriminator"
|
|
4
4
|
require "openapi3_parser/node_factory/object"
|
|
5
5
|
|
|
6
6
|
module Openapi3Parser
|
|
@@ -16,7 +16,7 @@ module Openapi3Parser
|
|
|
16
16
|
private
|
|
17
17
|
|
|
18
18
|
def build_object(data, context)
|
|
19
|
-
|
|
19
|
+
Node::Discriminator.new(data, context)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def validate_mapping(input)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "openapi3_parser/
|
|
3
|
+
require "openapi3_parser/node/encoding"
|
|
4
4
|
require "openapi3_parser/node_factory/object"
|
|
5
5
|
require "openapi3_parser/node_factory/optional_reference"
|
|
6
6
|
require "openapi3_parser/node_factories/map"
|
|
@@ -16,19 +16,23 @@ module Openapi3Parser
|
|
|
16
16
|
field "contentType", input_type: String
|
|
17
17
|
field "headers", factory: :headers_factory
|
|
18
18
|
field "style", input_type: String
|
|
19
|
-
field "explode", input_type: :boolean, default:
|
|
19
|
+
field "explode", input_type: :boolean, default: :default_explode
|
|
20
20
|
field "allowReserved", input_type: :boolean, default: false
|
|
21
21
|
|
|
22
22
|
private
|
|
23
23
|
|
|
24
24
|
def build_object(data, context)
|
|
25
|
-
|
|
25
|
+
Node::Encoding.new(data, context)
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def headers_factory(context)
|
|
29
29
|
factory = NodeFactory::OptionalReference.new(NodeFactories::Header)
|
|
30
30
|
NodeFactories::Map.new(context, value_factory: factory)
|
|
31
31
|
end
|
|
32
|
+
|
|
33
|
+
def default_explode
|
|
34
|
+
context.input["style"] == "form"
|
|
35
|
+
end
|
|
32
36
|
end
|
|
33
37
|
end
|
|
34
38
|
end
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "openapi3_parser/
|
|
3
|
+
require "openapi3_parser/node/example"
|
|
4
4
|
require "openapi3_parser/node_factory/object"
|
|
5
|
+
require "openapi3_parser/validators/url"
|
|
5
6
|
|
|
6
7
|
module Openapi3Parser
|
|
7
8
|
module NodeFactories
|
|
@@ -13,12 +14,16 @@ module Openapi3Parser
|
|
|
13
14
|
field "summary", input_type: String
|
|
14
15
|
field "description", input_type: String
|
|
15
16
|
field "value"
|
|
16
|
-
field "externalValue",
|
|
17
|
+
field "externalValue",
|
|
18
|
+
input_type: String,
|
|
19
|
+
validate: ->(input) { Validators::Url.call(input) }
|
|
20
|
+
|
|
21
|
+
mutually_exclusive "value", "externalValue"
|
|
17
22
|
|
|
18
23
|
private
|
|
19
24
|
|
|
20
25
|
def build_object(data, context)
|
|
21
|
-
|
|
26
|
+
Node::Example.new(data, context)
|
|
22
27
|
end
|
|
23
28
|
end
|
|
24
29
|
end
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "openapi3_parser/
|
|
3
|
+
require "openapi3_parser/node/external_documentation"
|
|
4
4
|
require "openapi3_parser/node_factory/object"
|
|
5
|
+
require "openapi3_parser/validators/url"
|
|
5
6
|
|
|
6
7
|
module Openapi3Parser
|
|
7
8
|
module NodeFactories
|
|
@@ -11,12 +12,15 @@ module Openapi3Parser
|
|
|
11
12
|
allow_extensions
|
|
12
13
|
|
|
13
14
|
field "description", input_type: String
|
|
14
|
-
field "url",
|
|
15
|
+
field "url",
|
|
16
|
+
required: true,
|
|
17
|
+
input_type: String,
|
|
18
|
+
validate: ->(input) { Validators::Url.call(input) }
|
|
15
19
|
|
|
16
20
|
private
|
|
17
21
|
|
|
18
22
|
def build_object(data, context)
|
|
19
|
-
|
|
23
|
+
Node::ExternalDocumentation.new(data, context)
|
|
20
24
|
end
|
|
21
25
|
end
|
|
22
26
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "openapi3_parser/
|
|
3
|
+
require "openapi3_parser/node/header"
|
|
4
4
|
require "openapi3_parser/node_factories/parameter/parameter_like"
|
|
5
5
|
require "openapi3_parser/node_factory/object"
|
|
6
6
|
|
|
@@ -29,7 +29,7 @@ module Openapi3Parser
|
|
|
29
29
|
private
|
|
30
30
|
|
|
31
31
|
def build_object(data, context)
|
|
32
|
-
|
|
32
|
+
Node::Header.new(data, context)
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
end
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "openapi3_parser/
|
|
3
|
+
require "openapi3_parser/node/info"
|
|
4
4
|
require "openapi3_parser/node_factories/license"
|
|
5
5
|
require "openapi3_parser/node_factories/contact"
|
|
6
6
|
require "openapi3_parser/node_factory/object"
|
|
7
|
+
require "openapi3_parser/validators/url"
|
|
7
8
|
|
|
8
9
|
module Openapi3Parser
|
|
9
10
|
module NodeFactories
|
|
@@ -13,7 +14,9 @@ module Openapi3Parser
|
|
|
13
14
|
allow_extensions
|
|
14
15
|
field "title", input_type: String, required: true
|
|
15
16
|
field "description", input_type: String
|
|
16
|
-
field "termsOfService",
|
|
17
|
+
field "termsOfService",
|
|
18
|
+
input_type: String,
|
|
19
|
+
validate: ->(input) { Validators::Url.call(input) }
|
|
17
20
|
field "contact", factory: Contact
|
|
18
21
|
field "license", factory: License
|
|
19
22
|
field "version", input_type: String, required: true
|
|
@@ -21,7 +24,7 @@ module Openapi3Parser
|
|
|
21
24
|
private
|
|
22
25
|
|
|
23
26
|
def build_object(data, context)
|
|
24
|
-
|
|
27
|
+
Node::Info.new(data, context)
|
|
25
28
|
end
|
|
26
29
|
end
|
|
27
30
|
end
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "openapi3_parser/
|
|
3
|
+
require "openapi3_parser/node/license"
|
|
4
4
|
require "openapi3_parser/node_factory/object"
|
|
5
|
+
require "openapi3_parser/validators/url"
|
|
5
6
|
|
|
6
7
|
module Openapi3Parser
|
|
7
8
|
module NodeFactories
|
|
@@ -10,12 +11,14 @@ module Openapi3Parser
|
|
|
10
11
|
|
|
11
12
|
allow_extensions
|
|
12
13
|
field "name", input_type: String, required: true
|
|
13
|
-
field "url",
|
|
14
|
+
field "url",
|
|
15
|
+
input_type: String,
|
|
16
|
+
validate: ->(input) { Validators::Url.call(input) }
|
|
14
17
|
|
|
15
18
|
private
|
|
16
19
|
|
|
17
20
|
def build_object(data, context)
|
|
18
|
-
|
|
21
|
+
Node::License.new(data, context)
|
|
19
22
|
end
|
|
20
23
|
end
|
|
21
24
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "openapi3_parser/
|
|
3
|
+
require "openapi3_parser/node/license"
|
|
4
4
|
require "openapi3_parser/node_factory/object"
|
|
5
5
|
require "openapi3_parser/node_factories/map"
|
|
6
6
|
require "openapi3_parser/node_factories/server"
|
|
@@ -22,10 +22,12 @@ module Openapi3Parser
|
|
|
22
22
|
field "description", input_type: String
|
|
23
23
|
field "server", factory: :server_factory
|
|
24
24
|
|
|
25
|
+
mutually_exclusive "operationRef", "operationId", required: true
|
|
26
|
+
|
|
25
27
|
private
|
|
26
28
|
|
|
27
29
|
def build_object(data, context)
|
|
28
|
-
|
|
30
|
+
Node::Link.new(data, context)
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
def parameters_factory(context)
|