swagger-blocks 2.0.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/ISSUE_TEMPLATE.md +4 -0
- data/lib/swagger/blocks.rb +14 -0
- data/lib/swagger/blocks/class_methods.rb +16 -2
- data/lib/swagger/blocks/internal_helpers.rb +25 -0
- data/lib/swagger/blocks/node.rb +48 -10
- data/lib/swagger/blocks/nodes/all_of_node.rb +6 -5
- data/lib/swagger/blocks/nodes/callback_destination_node.rb +11 -0
- data/lib/swagger/blocks/nodes/callback_method_node.rb +16 -0
- data/lib/swagger/blocks/nodes/callback_node.rb +11 -0
- data/lib/swagger/blocks/nodes/component_node.rb +50 -0
- data/lib/swagger/blocks/nodes/content_node.rb +20 -0
- data/lib/swagger/blocks/nodes/example_node.rb +3 -1
- data/lib/swagger/blocks/nodes/flow_node.rb +11 -0
- data/lib/swagger/blocks/nodes/header_node.rb +4 -0
- data/lib/swagger/blocks/nodes/items_node.rb +1 -1
- data/lib/swagger/blocks/nodes/link_node.rb +11 -0
- data/lib/swagger/blocks/nodes/link_parameter_node.rb +8 -0
- data/lib/swagger/blocks/nodes/one_of_node.rb +11 -0
- data/lib/swagger/blocks/nodes/operation_node.rb +15 -0
- data/lib/swagger/blocks/nodes/parameter_node.rb +5 -0
- data/lib/swagger/blocks/nodes/path_node.rb +6 -0
- data/lib/swagger/blocks/nodes/property_node.rb +5 -0
- data/lib/swagger/blocks/nodes/request_body_node.rb +12 -0
- data/lib/swagger/blocks/nodes/response_node.rb +17 -4
- data/lib/swagger/blocks/nodes/root_node.rb +16 -2
- data/lib/swagger/blocks/nodes/schema_node.rb +9 -0
- data/lib/swagger/blocks/nodes/scopes_node.rb +0 -1
- data/lib/swagger/blocks/nodes/security_scheme_node.rb +5 -1
- data/lib/swagger/blocks/nodes/server_node.rb +12 -0
- data/lib/swagger/blocks/nodes/value_node.rb +8 -0
- data/lib/swagger/blocks/nodes/variable_node.rb +8 -0
- data/lib/swagger/blocks/nodes/vendor_extension_node.rb +9 -0
- data/lib/swagger/blocks/root.rb +8 -1
- data/lib/swagger/blocks/version.rb +1 -1
- data/spec/lib/swagger_v2_blocks_spec.rb +1 -1
- data/spec/lib/swagger_v3_api_declaration.json +592 -0
- data/spec/lib/swagger_v3_blocks_spec.rb +555 -0
- metadata +22 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 32f19fd2faba19b9d8fd4111231781cc850037de8aa3042b7d0b7c35093370d4
|
4
|
+
data.tar.gz: 5799cb21a1651e9845d833aae1ee3eb318a475f31d204147e332b0a7c7305251
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed7faabe133513535df3165f36d090ef3a8fbc7171d04d0d820c0f673fe118117b5ddbd23790175099224a8c1a56c495ddb15ec7306d2cf038de331ef5b48cff
|
7
|
+
data.tar.gz: 2a8ea7db734e7093086f5e8a75d15af7f8208a37c89d172a4f0af7fd12aff91c1c23ca9eaa4a21089d4150092114ae8c21dde7ea004b0629b3497383a73141c3
|
data/lib/swagger/blocks.rb
CHANGED
@@ -9,26 +9,40 @@ module Swagger
|
|
9
9
|
|
10
10
|
module Nodes
|
11
11
|
autoload :AllOfNode, 'swagger/blocks/nodes/all_of_node'
|
12
|
+
autoload :CallbackNode, 'swagger/blocks/nodes/callback_node'
|
13
|
+
autoload :CallbackDestinationNode, 'swagger/blocks/nodes/callback_destination_node'
|
14
|
+
autoload :CallbackMethodNode, 'swagger/blocks/nodes/callback_method_node'
|
15
|
+
autoload :ComponentNode, 'swagger/blocks/nodes/component_node'
|
12
16
|
autoload :ContactNode, 'swagger/blocks/nodes/contact_node'
|
17
|
+
autoload :ContentNode, 'swagger/blocks/nodes/content_node'
|
13
18
|
autoload :ExampleNode, 'swagger/blocks/nodes/example_node'
|
14
19
|
autoload :ExternalDocsNode, 'swagger/blocks/nodes/external_docs_node'
|
20
|
+
autoload :FlowNode, 'swagger/blocks/nodes/flow_node'
|
15
21
|
autoload :HeaderNode, 'swagger/blocks/nodes/header_node'
|
16
22
|
autoload :InfoNode, 'swagger/blocks/nodes/info_node'
|
17
23
|
autoload :ItemsNode, 'swagger/blocks/nodes/items_node'
|
18
24
|
autoload :LicenseNode, 'swagger/blocks/nodes/license_node'
|
25
|
+
autoload :LinkNode, 'swagger/blocks/nodes/link_node'
|
26
|
+
autoload :LinkParameterNode, 'swagger/blocks/nodes/link_parameter_node'
|
27
|
+
autoload :OneOfNode, 'swagger/blocks/nodes/one_of_node'
|
19
28
|
autoload :OperationNode, 'swagger/blocks/nodes/operation_node'
|
20
29
|
autoload :ParameterNode, 'swagger/blocks/nodes/parameter_node'
|
21
30
|
autoload :PathNode, 'swagger/blocks/nodes/path_node'
|
22
31
|
autoload :PropertiesNode, 'swagger/blocks/nodes/properties_node'
|
23
32
|
autoload :PropertyNode, 'swagger/blocks/nodes/property_node'
|
33
|
+
autoload :RequestBodyNode, 'swagger/blocks/nodes/request_body_node'
|
24
34
|
autoload :ResponseNode, 'swagger/blocks/nodes/response_node'
|
25
35
|
autoload :RootNode, 'swagger/blocks/nodes/root_node'
|
26
36
|
autoload :SchemaNode, 'swagger/blocks/nodes/schema_node'
|
27
37
|
autoload :ScopesNode, 'swagger/blocks/nodes/scopes_node'
|
28
38
|
autoload :SecurityRequirementNode, 'swagger/blocks/nodes/security_requirement_node'
|
29
39
|
autoload :SecuritySchemeNode, 'swagger/blocks/nodes/security_scheme_node'
|
40
|
+
autoload :ServerNode, 'swagger/blocks/nodes/server_node'
|
30
41
|
autoload :TagNode, 'swagger/blocks/nodes/tag_node'
|
42
|
+
autoload :ValueNode, 'swagger/blocks/nodes/value_node'
|
43
|
+
autoload :VariableNode, 'swagger/blocks/nodes/variable_node'
|
31
44
|
autoload :XmlNode, 'swagger/blocks/nodes/xml_node'
|
45
|
+
autoload :VendorExtensionNode, 'swagger/blocks/nodes/vendor_extension_node'
|
32
46
|
end
|
33
47
|
end
|
34
48
|
end
|
@@ -9,6 +9,14 @@ module Swagger
|
|
9
9
|
@swagger_root_node ||= Swagger::Blocks::Nodes::RootNode.call(inline_keys: inline_keys, &block)
|
10
10
|
end
|
11
11
|
|
12
|
+
def version
|
13
|
+
if defined?(@swagger_root_node) && @swagger_root_node.data[:info] && @swagger_root_node.data[:info].version == '3.0.0'
|
14
|
+
'3.0.0'
|
15
|
+
else
|
16
|
+
'2.0'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
12
20
|
# v2.0: Defines a Swagger Path Item object
|
13
21
|
# https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#path-item-object
|
14
22
|
def swagger_path(path, &block)
|
@@ -25,7 +33,7 @@ module Swagger
|
|
25
33
|
path_node.instance_eval(&block)
|
26
34
|
else
|
27
35
|
# First time we've seen this path
|
28
|
-
@swagger_path_node_map[path] = Swagger::Blocks::Nodes::PathNode.call(version:
|
36
|
+
@swagger_path_node_map[path] = Swagger::Blocks::Nodes::PathNode.call(version: version, &block)
|
29
37
|
end
|
30
38
|
end
|
31
39
|
|
@@ -41,10 +49,14 @@ module Swagger
|
|
41
49
|
schema_node.instance_eval(&block)
|
42
50
|
else
|
43
51
|
# First time we've seen this schema_node
|
44
|
-
@swagger_schema_node_map[name] = Swagger::Blocks::Nodes::SchemaNode.call(version:
|
52
|
+
@swagger_schema_node_map[name] = Swagger::Blocks::Nodes::SchemaNode.call(version: version, inline_keys: inline_keys, &block)
|
45
53
|
end
|
46
54
|
end
|
47
55
|
|
56
|
+
def swagger_component(inline_keys = nil, &block)
|
57
|
+
@swagger_components_node ||= Swagger::Blocks::Nodes::ComponentNode.call(version: '3.0.0', inline_keys: inline_keys, &block)
|
58
|
+
end
|
59
|
+
|
48
60
|
def _swagger_nodes
|
49
61
|
# Avoid initialization warnings.
|
50
62
|
@swagger_root_node ||= nil
|
@@ -52,12 +64,14 @@ module Swagger
|
|
52
64
|
@swagger_schema_node_map ||= nil
|
53
65
|
@swagger_api_root_node_map ||= {}
|
54
66
|
@swagger_models_node ||= nil
|
67
|
+
@swagger_components_node ||= nil
|
55
68
|
|
56
69
|
data = {root_node: @swagger_root_node}
|
57
70
|
data[:path_node_map] = @swagger_path_node_map
|
58
71
|
data[:schema_node_map] = @swagger_schema_node_map
|
59
72
|
data[:api_node_map] = @swagger_api_root_node_map
|
60
73
|
data[:models_node] = @swagger_models_node
|
74
|
+
data[:component_node] = @swagger_components_node
|
61
75
|
data
|
62
76
|
end
|
63
77
|
end
|
@@ -10,6 +10,8 @@ module Swagger
|
|
10
10
|
|
11
11
|
path_node_map = {}
|
12
12
|
schema_node_map = {}
|
13
|
+
component_node = nil
|
14
|
+
|
13
15
|
swaggered_classes.each do |swaggered_class|
|
14
16
|
next unless swaggered_class.respond_to?(:_swagger_nodes, true)
|
15
17
|
swagger_nodes = swaggered_class.send(:_swagger_nodes)
|
@@ -23,11 +25,29 @@ module Swagger
|
|
23
25
|
if swagger_nodes[:schema_node_map]
|
24
26
|
schema_node_map.merge!(swagger_nodes[:schema_node_map])
|
25
27
|
end
|
28
|
+
if swagger_nodes[:component_node]
|
29
|
+
if component_node
|
30
|
+
merge_components(component_node, swagger_nodes, :examples)
|
31
|
+
merge_components(component_node, swagger_nodes, :links)
|
32
|
+
merge_components(component_node, swagger_nodes, :parameters)
|
33
|
+
merge_components(component_node, swagger_nodes, :requestBodies)
|
34
|
+
merge_components(component_node, swagger_nodes, :responses)
|
35
|
+
merge_components(component_node, swagger_nodes, :schemas)
|
36
|
+
merge_components(component_node, swagger_nodes, :securitySchemes)
|
37
|
+
else
|
38
|
+
component_node = swagger_nodes[:component_node]
|
39
|
+
end
|
40
|
+
end
|
26
41
|
end
|
42
|
+
|
27
43
|
data = {root_node: self.limit_root_node(root_nodes)}
|
44
|
+
|
28
45
|
if data[:root_node].is_swagger_2_0?
|
29
46
|
data[:path_nodes] = path_node_map
|
30
47
|
data[:schema_nodes] = schema_node_map
|
48
|
+
elsif data[:root_node].is_openapi_3_0?
|
49
|
+
data[:path_nodes] = path_node_map
|
50
|
+
data[:component_node] = component_node
|
31
51
|
else
|
32
52
|
data[:api_node_map] = api_node_map
|
33
53
|
data[:models_nodes] = models_nodes
|
@@ -35,6 +55,11 @@ module Swagger
|
|
35
55
|
data
|
36
56
|
end
|
37
57
|
|
58
|
+
def self.merge_components(component_node, swagger_nodes, key)
|
59
|
+
component_node.data[key] ||= {}
|
60
|
+
component_node.data[key].merge!(swagger_nodes[:component_node].data[key]) if swagger_nodes[:component_node].data[key]
|
61
|
+
end
|
62
|
+
|
38
63
|
# Make sure there is exactly one root_node and return it.
|
39
64
|
# TODO should this merge the contents of the root nodes instead?
|
40
65
|
def self.limit_root_node(root_nodes)
|
data/lib/swagger/blocks/node.rb
CHANGED
@@ -4,6 +4,8 @@ module Swagger
|
|
4
4
|
class Node
|
5
5
|
attr_accessor :name
|
6
6
|
attr_writer :version
|
7
|
+
VERSION_2 = '2.0'
|
8
|
+
VERSION_3 = '3.0.0'
|
7
9
|
|
8
10
|
def self.call(options = {}, &block)
|
9
11
|
# Create a new instance and evaluate the block into it.
|
@@ -15,20 +17,35 @@ module Swagger
|
|
15
17
|
instance
|
16
18
|
end
|
17
19
|
|
18
|
-
def as_json
|
19
|
-
|
20
|
+
def as_json(options = {})
|
21
|
+
version = options.fetch(:version, VERSION_2)
|
20
22
|
|
23
|
+
result = {}
|
21
24
|
self.data.each do |key, value|
|
22
25
|
if value.is_a?(Node)
|
23
|
-
result[key] = value.as_json
|
26
|
+
result[key] = value.as_json(version: version)
|
24
27
|
elsif value.is_a?(Array)
|
25
28
|
result[key] = []
|
26
|
-
value.each
|
27
|
-
|
29
|
+
value.each do |v|
|
30
|
+
result[key] << value_as_json(v, version)
|
31
|
+
end
|
32
|
+
elsif value.is_a?(Hash)
|
28
33
|
result[key] = {}
|
29
|
-
value.each_pair {|k, v| result[key][k] = (v
|
30
|
-
elsif
|
34
|
+
value.each_pair {|k, v| result[key][k] = value_as_json(v, version) }
|
35
|
+
elsif version == VERSION_2 && ref?(key) && !static_ref?(value)
|
31
36
|
result[key] = "#/definitions/#{value}"
|
37
|
+
elsif version == VERSION_3 && ref?(key) && self.is_a?(Swagger::Blocks::Nodes::LinkNode) && !static_ref?(value)
|
38
|
+
result[key] = "#/components/links/#{value}"
|
39
|
+
elsif version == VERSION_3 && ref?(key) && self.is_a?(Swagger::Blocks::Nodes::ExampleNode) && !static_ref?(value)
|
40
|
+
result[key] = "#/components/examples/#{value}"
|
41
|
+
elsif version == VERSION_3 && ref?(key) && self.is_a?(Swagger::Blocks::Nodes::ParameterNode) && !static_ref?(value)
|
42
|
+
result[key] = "#/components/parameters/#{value}"
|
43
|
+
elsif version == VERSION_3 && ref?(key) && self.is_a?(Swagger::Blocks::Nodes::RequestBodyNode) && !static_ref?(value)
|
44
|
+
result[key] = "#/components/requestBodies/#{value}"
|
45
|
+
elsif version == VERSION_3 && ref?(key) && self.is_a?(Swagger::Blocks::Nodes::ResponseNode) && !static_ref?(value)
|
46
|
+
result[key] = "#/components/responses/#{value}"
|
47
|
+
elsif version == VERSION_3 && ref?(key) && !static_ref?(value)
|
48
|
+
result[key] = "#/components/schemas/#{value}"
|
32
49
|
else
|
33
50
|
result[key] = value
|
34
51
|
end
|
@@ -38,6 +55,22 @@ module Swagger
|
|
38
55
|
{name => result}
|
39
56
|
end
|
40
57
|
|
58
|
+
def ref?(key)
|
59
|
+
key.to_s.eql?('$ref')
|
60
|
+
end
|
61
|
+
|
62
|
+
def static_ref?(value)
|
63
|
+
value.to_s =~ %r{^#/|https?://}
|
64
|
+
end
|
65
|
+
|
66
|
+
def value_as_json(value, version)
|
67
|
+
if value.respond_to?(:as_json)
|
68
|
+
value.as_json(version: version)
|
69
|
+
else
|
70
|
+
value
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
41
74
|
def data
|
42
75
|
@data ||= {}
|
43
76
|
end
|
@@ -52,12 +85,17 @@ module Swagger
|
|
52
85
|
|
53
86
|
def version
|
54
87
|
return @version if instance_variable_defined?('@version') && @version
|
55
|
-
return
|
56
|
-
|
88
|
+
return VERSION_2 if data.has_key?(:swagger) && data[:swagger] == VERSION_2
|
89
|
+
return VERSION_3 if data.has_key?(:openapi) && data[:openapi] == VERSION_3
|
90
|
+
raise DeclarationError, "You must specify swagger '#{VERSION_2}' or openapi '#{VERSION_3}'"
|
57
91
|
end
|
58
92
|
|
59
93
|
def is_swagger_2_0?
|
60
|
-
version ==
|
94
|
+
version == VERSION_2
|
95
|
+
end
|
96
|
+
|
97
|
+
def is_openapi_3_0?
|
98
|
+
version == VERSION_3
|
61
99
|
end
|
62
100
|
end
|
63
101
|
end
|
@@ -2,19 +2,20 @@ module Swagger
|
|
2
2
|
module Blocks
|
3
3
|
module Nodes
|
4
4
|
class AllOfNode < Node
|
5
|
-
def as_json
|
5
|
+
def as_json(options = {})
|
6
|
+
version = options.fetch(:version, '2.0')
|
6
7
|
result = []
|
7
8
|
|
8
9
|
self.data.each do |value|
|
9
10
|
if value.is_a?(Node)
|
10
|
-
result << value.as_json
|
11
|
+
result << value.as_json(version: version)
|
11
12
|
elsif value.is_a?(Array)
|
12
13
|
r = []
|
13
|
-
value.each { |v| r << (v
|
14
|
+
value.each { |v| r << value_as_json(v, version) }
|
14
15
|
result << r
|
15
|
-
elsif is_swagger_2_0? && value.is_a?(Hash)
|
16
|
+
elsif (is_swagger_2_0? || is_openapi_3_0?) && value.is_a?(Hash)
|
16
17
|
r = {}
|
17
|
-
value.each_pair {|k, v| r[k] = (v
|
18
|
+
value.each_pair {|k, v| r[k] = value_as_json(v, version) }
|
18
19
|
result << r
|
19
20
|
else
|
20
21
|
result = value
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Swagger
|
2
|
+
module Blocks
|
3
|
+
module Nodes
|
4
|
+
class CallbackDestinationNode < Node
|
5
|
+
def method(method_name, inline_keys = nil, &block)
|
6
|
+
self.data[method_name] = Swagger::Blocks::Nodes::CallbackMethodNode.call(version: version, inline_keys: inline_keys, &block)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Swagger
|
2
|
+
module Blocks
|
3
|
+
module Nodes
|
4
|
+
class CallbackMethodNode < Node
|
5
|
+
def request_body(inline_keys = nil, &block)
|
6
|
+
self.data[:requestBody] = Swagger::Blocks::Nodes::RequestBodyNode.call(version: version, inline_keys: inline_keys, &block)
|
7
|
+
end
|
8
|
+
|
9
|
+
def response(resp, inline_keys = nil, &block)
|
10
|
+
self.data[:responses] ||= {}
|
11
|
+
self.data[:responses][resp] = Swagger::Blocks::Nodes::ResponseNode.call(version: version, inline_keys: inline_keys, &block)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Swagger
|
2
|
+
module Blocks
|
3
|
+
module Nodes
|
4
|
+
class CallbackNode < Node
|
5
|
+
def destination(address, inline_keys = nil, &block)
|
6
|
+
self.data[address] = Swagger::Blocks::Nodes::CallbackDestinationNode.call(version: version, inline_keys: inline_keys, &block)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Swagger
|
2
|
+
module Blocks
|
3
|
+
module Nodes
|
4
|
+
class ComponentNode < Node
|
5
|
+
def schema(name, inline_keys = nil, &block)
|
6
|
+
self.data[:schemas] ||= {}
|
7
|
+
schema_node = self.data[:schemas][name]
|
8
|
+
|
9
|
+
if schema_node
|
10
|
+
# Merge this schema_node declaration into the previous one
|
11
|
+
schema_node.instance_eval(&block)
|
12
|
+
else
|
13
|
+
# First time we've seen this schema_node
|
14
|
+
self.data[:schemas][name] = Swagger::Blocks::Nodes::SchemaNode.call(version: '3.0.0', inline_keys: inline_keys, &block)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def link(name, inline_keys = nil, &block)
|
19
|
+
self.data[:links] ||= {}
|
20
|
+
self.data[:links][name] = Swagger::Blocks::Nodes::LinkNode.call(version: version, inline_keys: inline_keys, &block)
|
21
|
+
end
|
22
|
+
|
23
|
+
def example(name, inline_keys = nil, &block)
|
24
|
+
self.data[:examples] ||= {}
|
25
|
+
self.data[:examples][name] = Swagger::Blocks::Nodes::ExampleNode.call(version: version, inline_keys: inline_keys, &block)
|
26
|
+
end
|
27
|
+
|
28
|
+
def security_scheme(name, inline_keys = nil, &block)
|
29
|
+
self.data[:securitySchemes] ||= {}
|
30
|
+
self.data[:securitySchemes][name] = Swagger::Blocks::Nodes::SecuritySchemeNode.call(version: version, inline_keys: inline_keys, &block)
|
31
|
+
end
|
32
|
+
|
33
|
+
def parameter(name, inline_keys = nil, &block)
|
34
|
+
self.data[:parameters] ||= {}
|
35
|
+
self.data[:parameters][name] = Swagger::Blocks::Nodes::ParameterNode.call(version: version, inline_keys: inline_keys, &block)
|
36
|
+
end
|
37
|
+
|
38
|
+
def request_body(name, inline_keys = nil, &block)
|
39
|
+
self.data[:requestBodies] ||= {}
|
40
|
+
self.data[:requestBodies][name] = Swagger::Blocks::Nodes::RequestBodyNode.call(version: version, inline_keys: inline_keys, &block)
|
41
|
+
end
|
42
|
+
|
43
|
+
def response(name, inline_keys = nil, &block)
|
44
|
+
self.data[:responses] ||= {}
|
45
|
+
self.data[:responses][name] = Swagger::Blocks::Nodes::ResponseNode.call(version: version, inline_keys: inline_keys, &block)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Swagger
|
2
|
+
module Blocks
|
3
|
+
module Nodes
|
4
|
+
class ContentNode < Node
|
5
|
+
def schema(inline_keys = nil, &block)
|
6
|
+
self.data[:schema] = Swagger::Blocks::Nodes::SchemaNode.call(version: version, inline_keys: inline_keys, &block)
|
7
|
+
end
|
8
|
+
|
9
|
+
def example(name = nil, inline_keys = nil, &block)
|
10
|
+
if name.nil?
|
11
|
+
self.data[:example] = Swagger::Blocks::Nodes::ExampleNode.call(version: version, inline_keys: inline_keys, &block)
|
12
|
+
else
|
13
|
+
self.data[:examples] ||= {}
|
14
|
+
self.data[:examples][name] = Swagger::Blocks::Nodes::ExampleNode.call(version: version, inline_keys: inline_keys, &block)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
module Swagger
|
2
2
|
module Blocks
|
3
3
|
module Nodes
|
4
|
-
# v2.0:
|
5
4
|
class ExampleNode < Node
|
5
|
+
def value(inline_keys = nil, &block)
|
6
|
+
self.data[:value] = Swagger::Blocks::Nodes::ValueNode.call(version: version, inline_keys: inline_keys, &block)
|
7
|
+
end
|
6
8
|
end
|
7
9
|
end
|
8
10
|
end
|
@@ -6,6 +6,10 @@ module Swagger
|
|
6
6
|
def items(inline_keys = nil, &block)
|
7
7
|
self.data[:items] = Swagger::Blocks::Nodes::ItemsNode.call(version: version, inline_keys: inline_keys, &block)
|
8
8
|
end
|
9
|
+
|
10
|
+
def schema(inline_keys = nil, &block)
|
11
|
+
self.data[:schema] = Swagger::Blocks::Nodes::SchemaNode.call(version: version, inline_keys: inline_keys, &block)
|
12
|
+
end
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
@@ -8,7 +8,7 @@ module Swagger
|
|
8
8
|
self.data[:properties].version = version
|
9
9
|
self.data[:properties].property(name, inline_keys, &block)
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def items(inline_keys = nil, &block)
|
13
13
|
self.data[:items] = Swagger::Blocks::Nodes::ItemsNode.call(version: version, inline_keys: inline_keys, &block)
|
14
14
|
end
|