ruby-swagger 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruby-swagger.rb +1 -5
- data/lib/ruby-swagger/data/contact.rb +3 -8
- data/lib/ruby-swagger/data/definitions.rb +5 -7
- data/lib/ruby-swagger/data/document.rb +22 -24
- data/lib/ruby-swagger/data/example.rb +3 -5
- data/lib/ruby-swagger/data/external_documentation.rb +4 -6
- data/lib/ruby-swagger/data/header.rb +2 -4
- data/lib/ruby-swagger/data/headers.rb +5 -8
- data/lib/ruby-swagger/data/info.rb +6 -8
- data/lib/ruby-swagger/data/items.rb +4 -6
- data/lib/ruby-swagger/data/license.rb +4 -6
- data/lib/ruby-swagger/data/mime.rb +0 -2
- data/lib/ruby-swagger/data/operation.rb +7 -9
- data/lib/ruby-swagger/data/parameter.rb +4 -10
- data/lib/ruby-swagger/data/parameters.rb +4 -6
- data/lib/ruby-swagger/data/path.rb +14 -18
- data/lib/ruby-swagger/data/paths.rb +5 -7
- data/lib/ruby-swagger/data/reference.rb +4 -8
- data/lib/ruby-swagger/data/response.rb +1 -3
- data/lib/ruby-swagger/data/responses.rb +1 -3
- data/lib/ruby-swagger/data/schema.rb +7 -9
- data/lib/ruby-swagger/data/scopes.rb +4 -6
- data/lib/ruby-swagger/data/security_definitions.rb +5 -7
- data/lib/ruby-swagger/data/security_requirement.rb +6 -8
- data/lib/ruby-swagger/data/security_scheme.rb +10 -12
- data/lib/ruby-swagger/data/tag.rb +3 -5
- data/lib/ruby-swagger/data/url.rb +1 -3
- data/lib/ruby-swagger/data/xml_object.rb +2 -4
- data/lib/ruby-swagger/grape/entity.rb +41 -0
- data/lib/ruby-swagger/grape/entity_exposure.rb +96 -0
- data/lib/ruby-swagger/grape/entity_nesting_exposure.rb +38 -0
- data/lib/ruby-swagger/grape/grape.rb +1 -1
- data/lib/ruby-swagger/grape/grape_config.rb +19 -22
- data/lib/ruby-swagger/grape/grape_presenter.rb +6 -9
- data/lib/ruby-swagger/grape/grape_template.rb +3 -5
- data/lib/ruby-swagger/grape/method.rb +79 -71
- data/lib/ruby-swagger/grape/param.rb +3 -3
- data/lib/ruby-swagger/grape/route_path.rb +1 -3
- data/lib/ruby-swagger/grape/routes.rb +6 -9
- data/lib/ruby-swagger/grape/type.rb +46 -119
- data/lib/ruby-swagger/io/comparable.rb +13 -16
- data/lib/ruby-swagger/io/definitions.rb +5 -11
- data/lib/ruby-swagger/io/file_system.rb +8 -9
- data/lib/ruby-swagger/io/paths.rb +6 -11
- data/lib/ruby-swagger/io/security.rb +3 -6
- data/lib/ruby-swagger/object.rb +5 -7
- data/lib/ruby-swagger/railtie.rb +1 -1
- data/lib/ruby-swagger/template.rb +2 -4
- data/lib/tasks/swagger.rake +13 -18
- metadata +10 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d1aefb55567ede55aa051c96e6d6c9e3c8041fa
|
4
|
+
data.tar.gz: 7c2b67857e4d9a58347f4abadf180f1832f42c32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0afd868df01ae477ca6510e1157b95d2ff5c6e9f4e0bb7215b59184802b7d23b44e2bcb3c7b83a9567098da2868d061f2efa5d1078ee7e32e6cb40b7d00ea38
|
7
|
+
data.tar.gz: 953b8463f9866be1b997072c45972693c9895149e76c0e517607da7ff318cac77bda98d564f1a8f46adf47ba57bca94b6933e3c0a23449b19497de14fb07c20e
|
data/lib/ruby-swagger.rb
CHANGED
@@ -4,8 +4,7 @@ require 'ruby-swagger/data/url'
|
|
4
4
|
require 'ruby-swagger/object'
|
5
5
|
|
6
6
|
module Swagger::Data
|
7
|
-
class Contact < Swagger::Object #https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#contactObject
|
8
|
-
|
7
|
+
class Contact < Swagger::Object # https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#contactObject
|
9
8
|
DEFAULT_NAME = 'John Doe'
|
10
9
|
DEFAULT_EMAIL = 'john.doe@example.com'
|
11
10
|
DEFAULT_URL = 'https://google.com/?q=john%20doe'
|
@@ -20,16 +19,13 @@ module Swagger::Data
|
|
20
19
|
|
21
20
|
def self.parse(contact)
|
22
21
|
return nil unless contact
|
23
|
-
|
24
22
|
c = Swagger::Data::Contact.new.bulk_set(contact)
|
25
23
|
c.validate_url!
|
26
|
-
|
27
24
|
c
|
28
25
|
end
|
29
26
|
|
30
27
|
def url=(url)
|
31
28
|
return nil unless url
|
32
|
-
|
33
29
|
@url = Swagger::Data::Url.new(url)
|
34
30
|
end
|
35
31
|
|
@@ -42,8 +38,7 @@ module Swagger::Data
|
|
42
38
|
end
|
43
39
|
|
44
40
|
def validate_url!
|
45
|
-
raise
|
41
|
+
raise ArgumentError.new('Swagger::Data::Contact - contact url is invalid') if @url && !@url.valid?
|
46
42
|
end
|
47
|
-
|
48
43
|
end
|
49
|
-
end
|
44
|
+
end
|
@@ -2,8 +2,7 @@ require 'ruby-swagger/object'
|
|
2
2
|
require 'ruby-swagger/data/schema'
|
3
3
|
|
4
4
|
module Swagger::Data
|
5
|
-
class Definitions < Swagger::Object #https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#definitionsObject
|
6
|
-
|
5
|
+
class Definitions < Swagger::Object # https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#definitionsObject
|
7
6
|
def initialize
|
8
7
|
@definitions = {}
|
9
8
|
end
|
@@ -21,10 +20,10 @@ module Swagger::Data
|
|
21
20
|
end
|
22
21
|
|
23
22
|
def add_definition(definition_name, definition_value)
|
24
|
-
raise ArgumentError.new(
|
25
|
-
raise ArgumentError.new(
|
23
|
+
raise ArgumentError.new('Swagger::Data::Definitions#add_definition - definition_name is nil') unless definition_name
|
24
|
+
raise ArgumentError.new('Swagger::Data::Definitions#add_definition - definition_value is nil') unless definition_value
|
26
25
|
|
27
|
-
|
26
|
+
unless definition_value.is_a?(Swagger::Data::Schema)
|
28
27
|
definition_value = Swagger::Data::Schema.parse(definition_value)
|
29
28
|
end
|
30
29
|
|
@@ -44,6 +43,5 @@ module Swagger::Data
|
|
44
43
|
|
45
44
|
swagger_defs
|
46
45
|
end
|
47
|
-
|
48
46
|
end
|
49
|
-
end
|
47
|
+
end
|
@@ -12,9 +12,8 @@ require 'ruby-swagger/data/tag'
|
|
12
12
|
require 'ruby-swagger/data/external_documentation'
|
13
13
|
|
14
14
|
module Swagger::Data
|
15
|
-
class Document < Swagger::Object
|
16
|
-
|
17
|
-
SPEC_VERSION = '2.0' #https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#fixed-fields
|
15
|
+
class Document < Swagger::Object # https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#swagger-object
|
16
|
+
SPEC_VERSION = '2.0' # https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#fixed-fields
|
18
17
|
DEFAULT_HOST = 'localhost:80'
|
19
18
|
|
20
19
|
attr_swagger :swagger, :info, :host, :basePath, :schemes, :consumes,
|
@@ -31,18 +30,18 @@ module Swagger::Data
|
|
31
30
|
# parse an hash document into a set of Swagger objects
|
32
31
|
# document is a hash
|
33
32
|
def self.parse(document)
|
34
|
-
raise
|
33
|
+
raise ArgumentError.new('Swagger::Document#parse - document object is nil') unless document
|
35
34
|
|
36
35
|
Swagger::Data::Document.new.bulk_set(document)
|
37
36
|
end
|
38
37
|
|
39
38
|
def swagger=(new_swagger)
|
40
|
-
raise
|
39
|
+
raise ArgumentError.new("Swagger::Document#swagger= - the document is not a swagger #{SPEC_VERSION} version") unless '2.0' == new_swagger
|
41
40
|
@swagger = new_swagger
|
42
41
|
end
|
43
42
|
|
44
43
|
def info=(new_info)
|
45
|
-
raise
|
44
|
+
raise ArgumentError.new('Swagger::Document#info= - info object is nil') unless new_info
|
46
45
|
|
47
46
|
new_info = Swagger::Data::Info.parse(new_info) unless new_info.is_a?(Swagger::Data::Info)
|
48
47
|
|
@@ -52,8 +51,8 @@ module Swagger::Data
|
|
52
51
|
def basePath=(new_path)
|
53
52
|
new_path = new_path.nil? ? '/' : new_path
|
54
53
|
|
55
|
-
|
56
|
-
new_path = "/#{new_path}" #new path must start with a /
|
54
|
+
unless new_path =~ /^\/.+$/
|
55
|
+
new_path = "/#{new_path}" # new path must start with a /
|
57
56
|
end
|
58
57
|
|
59
58
|
@basePath ||= new_path
|
@@ -63,7 +62,7 @@ module Swagger::Data
|
|
63
62
|
return nil unless new_schemes
|
64
63
|
|
65
64
|
new_schemes.each do |scheme|
|
66
|
-
raise
|
65
|
+
raise ArgumentError.new("Swagger::Data::Document#schemes= - unrecognized scheme #{scheme}") unless %w(http https ws wss).include?(scheme)
|
67
66
|
end
|
68
67
|
|
69
68
|
@schemes = new_schemes
|
@@ -73,7 +72,7 @@ module Swagger::Data
|
|
73
72
|
return nil unless new_produces
|
74
73
|
|
75
74
|
new_produces.each do |produce|
|
76
|
-
raise
|
75
|
+
raise ArgumentError.new("Swagger::Data::Document#produces= - unrecognized produce type #{produce}") unless Swagger::Data::Mime.valid?(produce)
|
77
76
|
end
|
78
77
|
|
79
78
|
@produces = new_produces
|
@@ -83,16 +82,16 @@ module Swagger::Data
|
|
83
82
|
return nil unless new_consumes
|
84
83
|
|
85
84
|
new_consumes.each do |consume|
|
86
|
-
raise
|
85
|
+
raise ArgumentError.new("Swagger::Data::Document#consumes= - unrecognized consume type #{consume}]") unless Swagger::Data::Mime.valid?(consume)
|
87
86
|
end
|
88
87
|
|
89
|
-
@consumes= new_consumes
|
88
|
+
@consumes = new_consumes
|
90
89
|
end
|
91
90
|
|
92
91
|
def paths=(new_paths)
|
93
|
-
raise ArgumentError.new(
|
92
|
+
raise ArgumentError.new('Swagger::Data::Document#paths= - paths is nil') unless paths
|
94
93
|
|
95
|
-
new_paths = Swagger::Data::Paths.parse(new_paths)
|
94
|
+
new_paths = Swagger::Data::Paths.parse(new_paths) unless new_paths.is_a?(Swagger::Data::Paths)
|
96
95
|
|
97
96
|
@paths = new_paths
|
98
97
|
end
|
@@ -100,7 +99,7 @@ module Swagger::Data
|
|
100
99
|
def definitions=(new_definitions)
|
101
100
|
return nil unless new_definitions
|
102
101
|
|
103
|
-
|
102
|
+
unless new_definitions.is_a?(Swagger::Data::Definitions)
|
104
103
|
new_definitions = Swagger::Data::Definitions.parse(new_definitions)
|
105
104
|
end
|
106
105
|
|
@@ -110,7 +109,7 @@ module Swagger::Data
|
|
110
109
|
def parameters=(new_parameters)
|
111
110
|
return nil unless new_parameters
|
112
111
|
|
113
|
-
|
112
|
+
unless new_parameters.is_a?(Swagger::Data::Parameters)
|
114
113
|
new_parameters = Swagger::Data::Parameters.parse(new_parameters)
|
115
114
|
end
|
116
115
|
|
@@ -120,7 +119,7 @@ module Swagger::Data
|
|
120
119
|
def responses=(new_responses)
|
121
120
|
return nil unless new_responses
|
122
121
|
|
123
|
-
|
122
|
+
unless new_responses.is_a?(Swagger::Data::Responses)
|
124
123
|
new_responses = Swagger::Data::Responses.parse(new_responses)
|
125
124
|
end
|
126
125
|
|
@@ -130,17 +129,17 @@ module Swagger::Data
|
|
130
129
|
def securityDefinitions=(newSecurityDef)
|
131
130
|
return nil unless newSecurityDef
|
132
131
|
|
133
|
-
|
132
|
+
unless newSecurityDef.is_a?(Swagger::Data::SecurityDefinitions)
|
134
133
|
newSecurityDef = Swagger::Data::SecurityDefinitions.parse(newSecurityDef)
|
135
134
|
end
|
136
135
|
|
137
|
-
@securityDefinitions= newSecurityDef
|
136
|
+
@securityDefinitions = newSecurityDef
|
138
137
|
end
|
139
138
|
|
140
139
|
def security=(new_security)
|
141
140
|
return nil unless new_security
|
142
141
|
|
143
|
-
|
142
|
+
unless new_security.is_a?(Swagger::Data::SecurityRequirement)
|
144
143
|
new_security = Swagger::Data::SecurityRequirement.parse(new_security)
|
145
144
|
end
|
146
145
|
|
@@ -160,7 +159,7 @@ module Swagger::Data
|
|
160
159
|
def add_tag(new_tag)
|
161
160
|
return nil unless new_tag
|
162
161
|
|
163
|
-
|
162
|
+
unless new_tag.is_a?(Swagger::Data::Tag)
|
164
163
|
new_tag = Swagger::Data::Tag.parse(new_tag)
|
165
164
|
end
|
166
165
|
|
@@ -170,12 +169,11 @@ module Swagger::Data
|
|
170
169
|
def externalDocs=(new_externalDocs)
|
171
170
|
return nil unless new_externalDocs
|
172
171
|
|
173
|
-
|
172
|
+
unless new_externalDocs.is_a?(Swagger::Data::ExternalDocumentation)
|
174
173
|
new_externalDocs = Swagger::Data::ExternalDocumentation.parse(new_externalDocs)
|
175
174
|
end
|
176
175
|
|
177
176
|
@externalDocs = new_externalDocs
|
178
177
|
end
|
179
|
-
|
180
178
|
end
|
181
|
-
end
|
179
|
+
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'ruby-swagger/object'
|
2
2
|
|
3
3
|
module Swagger::Data
|
4
|
-
class Example < Swagger::Object #https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#exampleObject
|
5
|
-
|
4
|
+
class Example < Swagger::Object # https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#exampleObject
|
6
5
|
attr_accessor :examples
|
7
6
|
|
8
7
|
def initialize
|
@@ -15,7 +14,7 @@ module Swagger::Data
|
|
15
14
|
ex_obj = Swagger::Data::Example.new
|
16
15
|
|
17
16
|
examples = {}
|
18
|
-
new_examples.each {|example_mime, example| examples[example_mime] = example }
|
17
|
+
new_examples.each { |example_mime, example| examples[example_mime] = example }
|
19
18
|
ex_obj.examples = examples
|
20
19
|
|
21
20
|
ex_obj
|
@@ -24,6 +23,5 @@ module Swagger::Data
|
|
24
23
|
def as_swagger
|
25
24
|
@examples
|
26
25
|
end
|
27
|
-
|
28
26
|
end
|
29
|
-
end
|
27
|
+
end
|
@@ -1,12 +1,11 @@
|
|
1
1
|
require 'ruby-swagger/object'
|
2
2
|
|
3
3
|
module Swagger::Data
|
4
|
-
class ExternalDocumentation < Swagger::Object #https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#externalDocumentationObject
|
5
|
-
|
4
|
+
class ExternalDocumentation < Swagger::Object # https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#externalDocumentationObject
|
6
5
|
attr_swagger :url, :description
|
7
6
|
|
8
7
|
def initialize
|
9
|
-
@url =
|
8
|
+
@url = 'http://localhost'
|
10
9
|
end
|
11
10
|
|
12
11
|
def self.parse(external)
|
@@ -16,9 +15,8 @@ module Swagger::Data
|
|
16
15
|
end
|
17
16
|
|
18
17
|
def url=(new_url)
|
19
|
-
raise
|
18
|
+
raise ArgumentError.new('Swagger::Data::ExternalDocumentation#url - url is nil') unless new_url
|
20
19
|
@url = new_url
|
21
20
|
end
|
22
|
-
|
23
21
|
end
|
24
|
-
end
|
22
|
+
end
|
@@ -3,7 +3,6 @@ require 'ruby-swagger/data/items'
|
|
3
3
|
|
4
4
|
module Swagger::Data
|
5
5
|
class Header < Swagger::Object # https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#header-object
|
6
|
-
|
7
6
|
attr_swagger :description, :type, :format, :items,
|
8
7
|
:collectionFormat, :default, :maximum,
|
9
8
|
:exclusiveMaximum, :minimum, :exclusiveMinimum,
|
@@ -22,13 +21,12 @@ module Swagger::Data
|
|
22
21
|
end
|
23
22
|
|
24
23
|
def items=(new_items)
|
25
|
-
raise ArgumentError.new(
|
24
|
+
raise ArgumentError.new('Swagger::Data::Header#items= items is nil') if new_items.nil? && @type == 'array'
|
26
25
|
if !new_items.nil? && !new_items.is_a?(Swagger::Data::Items)
|
27
26
|
new_items = Swagger::Data::Items.parse(new_items)
|
28
27
|
end
|
29
28
|
|
30
29
|
@items = new_items
|
31
30
|
end
|
32
|
-
|
33
31
|
end
|
34
|
-
end
|
32
|
+
end
|
@@ -3,7 +3,6 @@ require 'ruby-swagger/data/header'
|
|
3
3
|
|
4
4
|
module Swagger::Data
|
5
5
|
class Headers < Swagger::Object # https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#headersObject
|
6
|
-
|
7
6
|
def initialize
|
8
7
|
@headers = {}
|
9
8
|
end
|
@@ -13,16 +12,16 @@ module Swagger::Data
|
|
13
12
|
|
14
13
|
h = Swagger::Data::Headers.new
|
15
14
|
|
16
|
-
headers.each {|header_key, header_value| h.add_header(header_key, header_value) }
|
15
|
+
headers.each { |header_key, header_value| h.add_header(header_key, header_value) }
|
17
16
|
|
18
17
|
h
|
19
18
|
end
|
20
19
|
|
21
20
|
def add_header(header_key, header_value)
|
22
|
-
raise ArgumentError.new(
|
23
|
-
raise ArgumentError.new(
|
21
|
+
raise ArgumentError.new('Swagger::Data::Headers#add_header - parameter name is nil') unless header_key
|
22
|
+
raise ArgumentError.new('Swagger::Data::Headers#add_header - parameter value is nil') unless header_value
|
24
23
|
|
25
|
-
|
24
|
+
unless header_value.is_a?(Swagger::Data::Header)
|
26
25
|
header_value = Swagger::Data::Header.parse(header_value)
|
27
26
|
end
|
28
27
|
|
@@ -42,7 +41,5 @@ module Swagger::Data
|
|
42
41
|
|
43
42
|
res
|
44
43
|
end
|
45
|
-
|
46
|
-
|
47
44
|
end
|
48
|
-
end
|
45
|
+
end
|
@@ -3,8 +3,7 @@ require 'ruby-swagger/data/contact'
|
|
3
3
|
require 'ruby-swagger/data/license'
|
4
4
|
|
5
5
|
module Swagger::Data
|
6
|
-
class Info < Swagger::Object
|
7
|
-
|
6
|
+
class Info < Swagger::Object # https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#info-object
|
8
7
|
DEFAULT_TITLE = 'My uber-duper API'
|
9
8
|
DEFAULT_DESCRIPTION = 'My uber-duper API description'
|
10
9
|
DEFAULT_VERSION = '0.1'
|
@@ -18,20 +17,20 @@ module Swagger::Data
|
|
18
17
|
end
|
19
18
|
|
20
19
|
def self.parse(info)
|
21
|
-
raise
|
20
|
+
raise ArgumentError.new('Swagger::Data::Info#parse - info object is nil') unless info
|
22
21
|
|
23
22
|
Swagger::Data::Info.new.bulk_set(info)
|
24
23
|
end
|
25
24
|
|
26
25
|
def title=(new_title)
|
27
|
-
raise
|
26
|
+
raise ArgumentError.new('Swagger::Data::Info#title= - title is invalid') if new_title.nil? || new_title.empty?
|
28
27
|
@title = new_title
|
29
28
|
end
|
30
29
|
|
31
30
|
def contact=(new_contact)
|
32
31
|
return nil unless new_contact
|
33
32
|
|
34
|
-
|
33
|
+
unless new_contact.is_a?(Swagger::Data::Contact)
|
35
34
|
new_contact = Swagger::Data::Contact.parse(new_contact)
|
36
35
|
end
|
37
36
|
|
@@ -41,7 +40,7 @@ module Swagger::Data
|
|
41
40
|
def license=(new_license)
|
42
41
|
return nil unless new_license
|
43
42
|
|
44
|
-
|
43
|
+
unless new_license.is_a?(Swagger::Data::License)
|
45
44
|
new_license = Swagger::Data::License.parse(new_license)
|
46
45
|
end
|
47
46
|
|
@@ -51,6 +50,5 @@ module Swagger::Data
|
|
51
50
|
def valid?
|
52
51
|
@license.valid? && @contact.valid?
|
53
52
|
end
|
54
|
-
|
55
53
|
end
|
56
|
-
end
|
54
|
+
end
|
@@ -2,14 +2,13 @@ require 'ruby-swagger/object'
|
|
2
2
|
|
3
3
|
module Swagger::Data
|
4
4
|
class Items < Swagger::Object # https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#itemsObject
|
5
|
-
|
6
5
|
attr_swagger :type, :format, :items, :collectionFormat, :default,
|
7
6
|
:maximum, :exclusiveMaximum, :minimum, :exclusiveMinimum,
|
8
7
|
:maxLength, :minLength, :pattern, :maxItems,
|
9
8
|
:minItems, :uniqueItems, :enum, :multipleOf
|
10
9
|
|
11
10
|
def initialize
|
12
|
-
@type =
|
11
|
+
@type = 'string' # we default to an array of strings
|
13
12
|
end
|
14
13
|
|
15
14
|
def self.parse(items)
|
@@ -19,14 +18,14 @@ module Swagger::Data
|
|
19
18
|
end
|
20
19
|
|
21
20
|
def type=(new_type)
|
22
|
-
raise ArgumentError.new(
|
21
|
+
raise ArgumentError.new('Swagger::Data::Items#type= - type is nil') unless new_type
|
23
22
|
raise ArgumentError.new("Swagger::Data::Items#type= - type #{new_type} is invalid") unless %w(string number integer boolean array).include?(new_type)
|
24
23
|
|
25
24
|
@type = new_type
|
26
25
|
end
|
27
26
|
|
28
27
|
def items=(new_items)
|
29
|
-
raise ArgumentError.new(
|
28
|
+
raise ArgumentError.new('Swagger::Data::Items#items= - is nil') if new_items.nil? && @type == 'array'
|
30
29
|
|
31
30
|
if !new_items.nil? && !new_items.is_a?(Swagger::Data::Items)
|
32
31
|
new_items = Swagger::Data::Items.parse(new_items)
|
@@ -40,6 +39,5 @@ module Swagger::Data
|
|
40
39
|
raise ArgumentError.new("Swagger::Data::Items#collectionFormat= - collectionFormat #{new_collection_format} is invalid") unless %w(csv ssv tsv pipes).include?(new_collection_format)
|
41
40
|
@collectionFormat = new_collection_format
|
42
41
|
end
|
43
|
-
|
44
42
|
end
|
45
|
-
end
|
43
|
+
end
|