swagger-core 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,10 @@
1
+ module Swagger
2
+ class URI < String
3
+ attr_reader :uri
4
+ def initialize(string)
5
+ # FIXME: Is it possible to initialize with heuristic parse once?
6
+ @uri = Addressable::URI.heuristic_parse string
7
+ super
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Swagger
2
+ class URITemplate < String
3
+ attr_reader :uri_template
4
+ def initialize(string)
5
+ # FIXME: Is it possible to initialize with heuristic parse once?
6
+ @uri_template = Addressable::Template.new string
7
+ super
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,81 @@
1
+ require 'json-schema'
2
+ require 'swagger/v2/info'
3
+ require 'swagger/v2/path'
4
+
5
+ module Swagger
6
+ module V2
7
+ SWAGGER_SCHEMA = File.expand_path 'schemas/swagger/v2.0/schema.json', Swagger::RESOURCES_DIR
8
+ JSON_SCHEMA = File.expand_path 'schemas/json_schema/draft-04.json', Swagger::RESOURCES_DIR
9
+
10
+ class APIDeclaration < Swagger::APIDeclaration
11
+ required_section :swagger, Float
12
+ required_section :info, Info
13
+ required_section :paths, Hash[String => Path]
14
+ section :host, Swagger::URITemplate
15
+ section :basePath, Swagger::URITemplate
16
+ section :schemes, Array[String]
17
+ section :consumes, Array[String]
18
+ section :produces, Array[String]
19
+ section :schemas, Hash
20
+ section :definitions, Hash
21
+ section :security, Array
22
+ # FIXME: Doesn't :parameter exist at this level as well?
23
+
24
+ attr_reader :apis
25
+
26
+ alias_method :base_path, :basePath
27
+
28
+ # def initialize(hash)
29
+ # super
30
+ # attach_to_apis
31
+ # end
32
+
33
+ def apis
34
+ # Perhaps not the best way...
35
+ paths.values.map do | path |
36
+ path.operations.values
37
+ end.flatten
38
+ end
39
+
40
+ def uri_template
41
+ # TODO: Can calculated values be safely memoized?
42
+ # TODO: Actual URI Template objects or just strings?
43
+ "#{host}#{basePath}"
44
+ end
45
+
46
+ def fully_validate
47
+ # FIXME: fully_validate is ideal, but very slow with the current schema/validator
48
+ errors = JSON::Validator.fully_validate(swagger_schema, to_json)
49
+ fail Swagger::InvalidDefinition, errors unless errors.empty?
50
+ true
51
+ end
52
+
53
+ def validate
54
+ JSON::Validator.validate!(swagger_schema, to_json)
55
+ rescue JSON::Schema::ValidationError => e
56
+ raise Swagger::InvalidDefinition, e.message
57
+ end
58
+
59
+ private
60
+
61
+ def swagger_schema
62
+ @swagger_schema ||= JSON.parse(File.read(SWAGGER_SCHEMA))
63
+
64
+ # Offline workaround
65
+ # @swagger_schema = JSON.parse(File.read(SWAGGER_SCHEMA)
66
+ # .gsub('http://json-schema.org/draft-04/schema', "file://#{SWAGGER_SCHEMA}"))
67
+ # @swagger_schema['$schema'] = 'http://json-schema.org/draft-04/schema#'
68
+ # @swagger_schema
69
+ end
70
+
71
+ # def attach_to_apis
72
+ # @apis ||= Set.new
73
+ # paths.each do |path, api|
74
+ # api.path = path
75
+ # api.parent = self
76
+ # @apis << api
77
+ # end
78
+ # end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,56 @@
1
+ require 'swagger/v2/parameter'
2
+ require 'swagger/v2/response'
3
+
4
+ module Swagger
5
+ module V2
6
+ class APIOperation < DefinitionSection
7
+ extend Forwardable
8
+ def_delegators :parent, :uri_template, :path, :host
9
+
10
+ # required_section :verb, Symbol
11
+ section :summary, String
12
+ section :description, String
13
+ section :operationId, String
14
+ section :produces, Array[String]
15
+ section :consumes, Array[String]
16
+ section :tags, Array[String]
17
+ section :parameters, Array[Parameter]
18
+ section :responses, Hash[String => Response]
19
+ section :schemes, Array[String]
20
+
21
+ def initialize(hash)
22
+ hash[:parameters] ||= []
23
+ super
24
+ end
25
+
26
+ def verb
27
+ parent.operations.key self
28
+ end
29
+
30
+ def default_response
31
+ return nil if responses.values.nil?
32
+
33
+ # FIXME: Swagger isn't very clear on "normal response codes"
34
+ # In the examples, default is actually an error
35
+ responses['200'] || responses['201'] || responses['default'] || responses.values.first
36
+ end
37
+
38
+ # def self.coerce(orig_hash)
39
+ # fail TypeError, 'Can only coerce from a hash' unless orig_hash.is_a? Hash
40
+ # top_level_parameters = orig_hash.delete :parameters
41
+
42
+ # new_hash = {
43
+ # verb: orig_hash.keys.first
44
+ # }.merge(orig_hash.values.first).merge(parameters: top_level_parameters)
45
+
46
+ # APIOperation.new(new_hash)
47
+ # end
48
+
49
+ # def to_hash
50
+ # base_hash = super
51
+ # base_hash.delete :verb
52
+ # { verb => base_hash }
53
+ # end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,24 @@
1
+ module Swagger
2
+ module V2
3
+ class Example
4
+ extend Forwardable
5
+ def_delegator :@raw, :to_s, :inspect
6
+
7
+ attr_reader :raw
8
+
9
+ def initialize(sample)
10
+ @raw = sample
11
+ end
12
+
13
+ def parse(_format = :json)
14
+ return @raw unless @raw.is_a? String
15
+
16
+ JSON.parse(@raw)
17
+ end
18
+
19
+ def inspect
20
+ @raw.inspect
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,23 @@
1
+ module Swagger
2
+ module V2
3
+ class Info < DefinitionSection
4
+ class Contact < DefinitionSection
5
+ section :name, String
6
+ section :url, Swagger::URI
7
+ section :email, String
8
+ end
9
+
10
+ class License < DefinitionSection
11
+ required_section :name, String
12
+ section :url, Swagger::URI
13
+ end
14
+
15
+ required_section :version, String
16
+ required_section :title, String
17
+ section :description, String
18
+ section :termsOfService, String
19
+ section :contact, Contact
20
+ section :license, License
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,6 @@
1
+ module Swagger
2
+ module V2
3
+ class Parameter < Hashie::Mash
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,38 @@
1
+ require 'swagger/v2/api_operation'
2
+
3
+ module Swagger
4
+ module V2
5
+ class Path < DefinitionSection
6
+ extend Forwardable
7
+ def_delegator :parent, :host
8
+
9
+ VERBS = [:get, :put, :post, :delete, :options, :head, :patch]
10
+
11
+ section :parameters, Array[Parameter]
12
+
13
+ VERBS.each do | verb |
14
+ section verb, APIOperation
15
+ end
16
+
17
+ def initialize(hash)
18
+ hash[:parameters] ||= []
19
+ super
20
+ end
21
+
22
+ def operations
23
+ VERBS.each_with_object({}) do | v, h |
24
+ operation = send v
25
+ h[v] = operation if operation
26
+ end
27
+ end
28
+
29
+ def uri_template
30
+ "#{parent.host}#{parent.base_path}#{path}"
31
+ end
32
+
33
+ def path
34
+ parent.paths.key self
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,21 @@
1
+ require 'swagger/v2/example'
2
+
3
+ module Swagger
4
+ module V2
5
+ class Response < DefinitionSection
6
+ section :description, String
7
+ section :schema, Swagger::Schema
8
+ section :headers, Array # [String => String] # TODO: Headers
9
+ section :examples, Hash[Swagger::MimeType => Example]
10
+
11
+ def status_code
12
+ code = parent.responses.key self
13
+ code = '200' if code == 'default'
14
+ code.to_i
15
+ rescue
16
+ # TODO: Warning?
17
+ 200
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module Swagger
2
+ VERSION = '0.2.0'
3
+ end
@@ -0,0 +1,150 @@
1
+ {
2
+ "id": "http://json-schema.org/draft-04/schema#",
3
+ "$schema": "http://json-schema.org/draft-04/schema#",
4
+ "description": "Core schema meta-schema",
5
+ "definitions": {
6
+ "schemaArray": {
7
+ "type": "array",
8
+ "minItems": 1,
9
+ "items": { "$ref": "#" }
10
+ },
11
+ "positiveInteger": {
12
+ "type": "integer",
13
+ "minimum": 0
14
+ },
15
+ "positiveIntegerDefault0": {
16
+ "allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ]
17
+ },
18
+ "simpleTypes": {
19
+ "enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ]
20
+ },
21
+ "stringArray": {
22
+ "type": "array",
23
+ "items": { "type": "string" },
24
+ "minItems": 1,
25
+ "uniqueItems": true
26
+ }
27
+ },
28
+ "type": "object",
29
+ "properties": {
30
+ "id": {
31
+ "type": "string",
32
+ "format": "uri"
33
+ },
34
+ "$schema": {
35
+ "type": "string",
36
+ "format": "uri"
37
+ },
38
+ "title": {
39
+ "type": "string"
40
+ },
41
+ "description": {
42
+ "type": "string"
43
+ },
44
+ "default": {},
45
+ "multipleOf": {
46
+ "type": "number",
47
+ "minimum": 0,
48
+ "exclusiveMinimum": true
49
+ },
50
+ "maximum": {
51
+ "type": "number"
52
+ },
53
+ "exclusiveMaximum": {
54
+ "type": "boolean",
55
+ "default": false
56
+ },
57
+ "minimum": {
58
+ "type": "number"
59
+ },
60
+ "exclusiveMinimum": {
61
+ "type": "boolean",
62
+ "default": false
63
+ },
64
+ "maxLength": { "$ref": "#/definitions/positiveInteger" },
65
+ "minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
66
+ "pattern": {
67
+ "type": "string",
68
+ "format": "regex"
69
+ },
70
+ "additionalItems": {
71
+ "anyOf": [
72
+ { "type": "boolean" },
73
+ { "$ref": "#" }
74
+ ],
75
+ "default": {}
76
+ },
77
+ "items": {
78
+ "anyOf": [
79
+ { "$ref": "#" },
80
+ { "$ref": "#/definitions/schemaArray" }
81
+ ],
82
+ "default": {}
83
+ },
84
+ "maxItems": { "$ref": "#/definitions/positiveInteger" },
85
+ "minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
86
+ "uniqueItems": {
87
+ "type": "boolean",
88
+ "default": false
89
+ },
90
+ "maxProperties": { "$ref": "#/definitions/positiveInteger" },
91
+ "minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
92
+ "required": { "$ref": "#/definitions/stringArray" },
93
+ "additionalProperties": {
94
+ "anyOf": [
95
+ { "type": "boolean" },
96
+ { "$ref": "#" }
97
+ ],
98
+ "default": {}
99
+ },
100
+ "definitions": {
101
+ "type": "object",
102
+ "additionalProperties": { "$ref": "#" },
103
+ "default": {}
104
+ },
105
+ "properties": {
106
+ "type": "object",
107
+ "additionalProperties": { "$ref": "#" },
108
+ "default": {}
109
+ },
110
+ "patternProperties": {
111
+ "type": "object",
112
+ "additionalProperties": { "$ref": "#" },
113
+ "default": {}
114
+ },
115
+ "dependencies": {
116
+ "type": "object",
117
+ "additionalProperties": {
118
+ "anyOf": [
119
+ { "$ref": "#" },
120
+ { "$ref": "#/definitions/stringArray" }
121
+ ]
122
+ }
123
+ },
124
+ "enum": {
125
+ "type": "array",
126
+ "minItems": 1,
127
+ "uniqueItems": true
128
+ },
129
+ "type": {
130
+ "anyOf": [
131
+ { "$ref": "#/definitions/simpleTypes" },
132
+ {
133
+ "type": "array",
134
+ "items": { "$ref": "#/definitions/simpleTypes" },
135
+ "minItems": 1,
136
+ "uniqueItems": true
137
+ }
138
+ ]
139
+ },
140
+ "allOf": { "$ref": "#/definitions/schemaArray" },
141
+ "anyOf": { "$ref": "#/definitions/schemaArray" },
142
+ "oneOf": { "$ref": "#/definitions/schemaArray" },
143
+ "not": { "$ref": "#" }
144
+ },
145
+ "dependencies": {
146
+ "exclusiveMaximum": [ "maximum" ],
147
+ "exclusiveMinimum": [ "minimum" ]
148
+ },
149
+ "default": {}
150
+ }
@@ -0,0 +1,532 @@
1
+ {
2
+ "title": "A JSON Schema for Swagger 2.0 API.",
3
+ "$schema": "http://json-schema.org/draft-04/schema#",
4
+
5
+ "type": "object",
6
+ "required": [ "swagger", "info", "paths" ],
7
+ "additionalProperties": false,
8
+ "patternProperties": {
9
+ "^x-": {
10
+ "$ref": "#/definitions/vendorExtension"
11
+ }
12
+ },
13
+ "properties": {
14
+ "swagger": {
15
+ "type": "number",
16
+ "enum": [ 2.0 ],
17
+ "description": "The Swagger version of this document."
18
+ },
19
+ "info": {
20
+ "$ref": "#/definitions/info"
21
+ },
22
+ "externalDocs": {
23
+ "$ref": "#/definitions/externalDocs"
24
+ },
25
+ "host": {
26
+ "type": "string",
27
+ "format": "uri",
28
+ "pattern": "^((?!\\:\/\/).)*$",
29
+ "description": "The fully qualified URI to the host of the API."
30
+ },
31
+ "basePath": {
32
+ "type": "string",
33
+ "pattern": "^/",
34
+ "description": "The base path to the API. Example: '/api'."
35
+ },
36
+ "schemes": {
37
+ "type": "array",
38
+ "description": "The transfer protocol of the API.",
39
+ "items": {
40
+ "type": "string",
41
+ "enum": [ "http", "https", "ws", "wss" ]
42
+ }
43
+ },
44
+ "consumes": {
45
+ "type": "array",
46
+ "description": "A list of MIME types accepted by the API.",
47
+ "items": {
48
+ "$ref": "#/definitions/mimeType"
49
+ }
50
+ },
51
+ "produces": {
52
+ "type": "array",
53
+ "description": "A list of MIME types the API can produce.",
54
+ "items": {
55
+ "$ref": "#/definitions/mimeType"
56
+ }
57
+ },
58
+ "paths": {
59
+ "type": "object",
60
+ "description": "Relative paths to the individual endpoints. They must be relative to the 'basePath'.",
61
+ "patternProperties": {
62
+ "^x-": {
63
+ "$ref": "#/definitions/vendorExtension"
64
+ },
65
+ "^/.*[^\/]$": {
66
+ "$ref": "#/definitions/pathItem"
67
+ }
68
+ },
69
+ "additionalProperties": false
70
+ },
71
+ "definitions": {
72
+ "type": "object",
73
+ "description": "One or more JSON objects describing the schemas being consumed and produced by the API.",
74
+ "additionalProperties": { "$ref": "#/definitions/schema" }
75
+ },
76
+ "parameters": {
77
+ "type": "object",
78
+ "description": "One or more JSON representations for parameters",
79
+ "additionalProperties": { "$ref": "#/definitions/parameter" }
80
+ },
81
+ "responses": { "$ref": "#/definitions/responses" },
82
+ "security": { "$ref": "#/definitions/security" },
83
+ "tags": {
84
+ "type": "array",
85
+ "items": {
86
+ "$ref": "#/definitions/tag"
87
+ }
88
+ }
89
+ },
90
+ "definitions": {
91
+ "externalDocs": {
92
+ "type": "object",
93
+ "description": "information about external documentation",
94
+ "required": [ "url" ],
95
+ "properties": {
96
+ "description": {
97
+ "type": "string"
98
+ },
99
+ "url": {
100
+ "type": "string",
101
+ "format": "uri"
102
+ }
103
+ }
104
+ },
105
+ "info": {
106
+ "type": "object",
107
+ "description": "General information about the API.",
108
+ "required": [ "version", "title" ],
109
+ "additionalProperties": false,
110
+ "patternProperties": {
111
+ "^x-": {
112
+ "$ref": "#/definitions/vendorExtension"
113
+ }
114
+ },
115
+ "properties": {
116
+ "version": {
117
+ "type": "string",
118
+ "description": "A semantic version number of the API."
119
+ },
120
+ "title": {
121
+ "type": "string",
122
+ "description": "A unique and precise title of the API."
123
+ },
124
+ "description": {
125
+ "type": "string",
126
+ "description": "A longer description of the API. Should be different from the title. Github-flavored markdown is allowed."
127
+ },
128
+ "termsOfService": {
129
+ "type": "string",
130
+ "description": "The terms of service for the API."
131
+ },
132
+ "contact": {
133
+ "type": "object",
134
+ "description": "Contact information for the owners of the API.",
135
+ "additionalProperties": false,
136
+ "properties": {
137
+ "name": {
138
+ "type": "string",
139
+ "description": "The identifying name of the contact person/organization."
140
+ },
141
+ "url": {
142
+ "type": "string",
143
+ "description": "The URL pointing to the contact information.",
144
+ "format": "uri"
145
+ },
146
+ "email": {
147
+ "type": "string",
148
+ "description": "The email address of the contact person/organization.",
149
+ "format": "email"
150
+ }
151
+ }
152
+ },
153
+ "license": {
154
+ "type": "object",
155
+ "required": [ "name" ],
156
+ "additionalProperties": false,
157
+ "properties": {
158
+ "name": {
159
+ "type": "string",
160
+ "description": "The name of the license type. It's encouraged to use an OSI compatible license."
161
+ },
162
+ "url": {
163
+ "type": "string",
164
+ "description": "The URL pointing to the license.",
165
+ "format": "uri"
166
+ }
167
+ }
168
+ }
169
+ }
170
+ },
171
+ "example": {
172
+ "type": "object",
173
+ "patternProperties": {
174
+ "^[a-z0-9-]+/[a-z0-9\\-+]+$": {}
175
+ },
176
+ "additionalProperties": false
177
+ },
178
+ "mimeType": {
179
+ "type": "string",
180
+ "pattern": "^[\\sa-z0-9\\-+;\\.=\\/]+$",
181
+ "description": "The MIME type of the HTTP message."
182
+ },
183
+ "operation": {
184
+ "type": "object",
185
+ "required": [ "responses" ],
186
+ "additionalProperties": false,
187
+ "patternProperties": {
188
+ "^x-": {
189
+ "$ref": "#/definitions/vendorExtension"
190
+ }
191
+ },
192
+ "properties": {
193
+ "tags": {
194
+ "type": "array",
195
+ "items": {
196
+ "type": "string"
197
+ }
198
+ },
199
+ "summary": {
200
+ "type": "string",
201
+ "description": "A brief summary of the operation."
202
+ },
203
+ "description": {
204
+ "type": "string",
205
+ "description": "A longer description of the operation, github-flavored markdown is allowed."
206
+ },
207
+ "externalDocs": {
208
+ "$ref": "#/definitions/externalDocs"
209
+ },
210
+ "operationId": {
211
+ "type": "string",
212
+ "description": "A friendly name of the operation"
213
+ },
214
+ "produces": {
215
+ "type": "array",
216
+ "description": "A list of MIME types the API can produce.",
217
+ "additionalItems": false,
218
+ "items": {
219
+ "$ref": "#/definitions/mimeType"
220
+ }
221
+ },
222
+ "consumes": {
223
+ "type": "array",
224
+ "description": "A list of MIME types the API can consume.",
225
+ "additionalItems": false,
226
+ "items": {
227
+ "$ref": "#/definitions/mimeType"
228
+ }
229
+ },
230
+ "parameters": {
231
+ "type": "array",
232
+ "description": "The parameters needed to send a valid API call.",
233
+ "minItems": 1,
234
+ "additionalItems": false,
235
+ "items": {
236
+ "oneOf": [
237
+ { "$ref": "#/definitions/parameter" },
238
+ {
239
+ "type": "object",
240
+ "additionalProperties": false,
241
+ "properties": {
242
+ "$ref": {
243
+ "type": "string"
244
+ }
245
+ }
246
+ }
247
+ ]
248
+ }
249
+ },
250
+ "responses": {
251
+ "$ref": "#/definitions/responses"
252
+ },
253
+ "schemes": {
254
+ "type": "array",
255
+ "description": "The transfer protocol of the API.",
256
+ "items": {
257
+ "type": "string",
258
+ "enum": [ "http", "https", "ws", "wss" ]
259
+ }
260
+ },
261
+ "security": {
262
+ "$ref": "#/definitions/securityRequirement"
263
+ }
264
+ }
265
+ },
266
+ "pathItem": {
267
+ "type": "object",
268
+ "additionalProperties": false,
269
+ "patternProperties": {
270
+ "^x-": {
271
+ "$ref": "#/definitions/vendorExtension"
272
+ }
273
+ },
274
+ "properties": {
275
+ "$ref": {
276
+ "type": "string"
277
+ },
278
+ "get": {
279
+ "$ref": "#/definitions/operation"
280
+ },
281
+ "put": {
282
+ "$ref": "#/definitions/operation"
283
+ },
284
+ "post": {
285
+ "$ref": "#/definitions/operation"
286
+ },
287
+ "delete": {
288
+ "$ref": "#/definitions/operation"
289
+ },
290
+ "options": {
291
+ "$ref": "#/definitions/operation"
292
+ },
293
+ "head": {
294
+ "$ref": "#/definitions/operation"
295
+ },
296
+ "patch": {
297
+ "$ref": "#/definitions/operation"
298
+ },
299
+ "parameters": {
300
+ "type": "array",
301
+ "items": {
302
+ "$ref": "#/definitions/parameter"
303
+ }
304
+ }
305
+ }
306
+ },
307
+ "responses": {
308
+ "type": "object",
309
+ "description": "Response objects names can either be any valid HTTP status code or 'default'.",
310
+ "minProperties": 1,
311
+ "additionalProperties": false,
312
+ "patternProperties": {
313
+ "^([0-9]+)$|^(default)$": {
314
+ "$ref": "#/definitions/response"
315
+ },
316
+ "^x-": {
317
+ "$ref": "#/definitions/vendorExtension"
318
+ }
319
+ }
320
+ },
321
+ "response": {
322
+ "type": "object",
323
+ "required": [ "description" ],
324
+ "properties": {
325
+ "description": {
326
+ "type": "string"
327
+ },
328
+ "schema": {
329
+ "$ref": "#/definitions/schema"
330
+ },
331
+ "headers": {
332
+ "type": "array",
333
+ "items": {
334
+ "$ref": "#/definitions/serializableType"
335
+ }
336
+ },
337
+ "examples": {
338
+ "$ref": "#/definitions/example"
339
+ }
340
+ },
341
+ "additionalProperties": false
342
+ },
343
+ "serializableType": {
344
+ "properties": {
345
+ "type": {
346
+ "type": "string",
347
+ "enum": [ "string", "number", "boolean", "integer", "array", "file" ]
348
+ },
349
+ "format": {
350
+ "type": "string"
351
+ },
352
+ "items": {
353
+ "type": "object"
354
+ },
355
+ "collectionFormat": {
356
+ "type": "string"
357
+ }
358
+ }
359
+ },
360
+ "vendorExtension": {
361
+ "description": "Any property starting with x- is valid.",
362
+ "additionalProperties": true,
363
+ "additionalItems": true
364
+ },
365
+ "parameter": {
366
+ "type": "object",
367
+ "required": [ "name", "in" ],
368
+ "oneOf": [
369
+ {
370
+ "patternProperties": {
371
+ "^x-": {
372
+ "$ref": "#/definitions/vendorExtension"
373
+ }
374
+ },
375
+ "properties": {
376
+ "name": {
377
+ "type": "string",
378
+ "description": "The name of the parameter."
379
+ },
380
+ "in": {
381
+ "type": "string",
382
+ "description": "Determines the location of the parameter.",
383
+ "enum": [ "query", "header", "path", "formData" ]
384
+ },
385
+ "description": {
386
+ "type": "string",
387
+ "description": "A brief description of the parameter. This could contain examples of use. Github-flavored markdown is allowed."
388
+ },
389
+ "required": {
390
+ "type": "boolean",
391
+ "description": "Determines whether or not this parameter is required or optional."
392
+ },
393
+ "type": {
394
+ "type": "string",
395
+ "enum": [ "string", "number", "boolean", "integer", "array" ]
396
+ },
397
+ "format": {
398
+ "type": "string"
399
+ },
400
+ "items": {
401
+ "type": "object"
402
+ },
403
+ "collectionFormat": {
404
+ "type": "string"
405
+ }
406
+ },
407
+ "additionalProperties": false
408
+ },
409
+ {
410
+ "patternProperties": {
411
+ "^x-": {
412
+ "$ref": "#/definitions/vendorExtension"
413
+ }
414
+ },
415
+ "properties": {
416
+ "name": {
417
+ "type": "string",
418
+ "description": "The name of the parameter."
419
+ },
420
+ "in": {
421
+ "type": "string",
422
+ "description": "Determines the location of the parameter.",
423
+ "enum": [ "body" ]
424
+ },
425
+ "description": {
426
+ "type": "string",
427
+ "description": "A brief description of the parameter. This could contain examples of use."
428
+ },
429
+ "required": {
430
+ "type": "boolean",
431
+ "description": "Determines whether or not this parameter is required or optional."
432
+ },
433
+ "schema": {
434
+ "$ref": "#/definitions/schema"
435
+ }
436
+ },
437
+ "additionalProperties": false
438
+ }
439
+ ]
440
+ },
441
+ "schema": {
442
+ "type": "object",
443
+ "description": "A deterministic version of a JSON Schema object.",
444
+ "patternProperties": {
445
+ "^x-": {
446
+ "$ref": "#/definitions/vendorExtension"
447
+ }
448
+ },
449
+ "properties": {
450
+ "$ref": { "type": "string" },
451
+ "format": { "type": "string" },
452
+ "title": { "$ref": "http://json-schema.org/draft-04/schema#/properties/title" },
453
+ "description": { "$ref": "http://json-schema.org/draft-04/schema#/properties/description" },
454
+ "default": { "$ref": "http://json-schema.org/draft-04/schema#/properties/default" },
455
+ "multipleOf": { "$ref": "http://json-schema.org/draft-04/schema#/properties/multipleOf" },
456
+ "maximum": { "$ref": "http://json-schema.org/draft-04/schema#/properties/maximum" },
457
+ "exclusiveMaximum": { "$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMaximum" },
458
+ "minimum": { "$ref": "http://json-schema.org/draft-04/schema#/properties/minimum" },
459
+ "exclusiveMinimum": { "$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMinimum" },
460
+ "maxLength": { "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger" },
461
+ "minLength": { "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0" },
462
+ "pattern": { "$ref": "http://json-schema.org/draft-04/schema#/properties/pattern" },
463
+ "discriminator": { "type": "string" },
464
+ "xml": { "$ref": "#/definitions/xml"},
465
+ "items": {
466
+ "anyOf": [
467
+ { "$ref": "#/definitions/schema" },
468
+ {
469
+ "type": "array",
470
+ "minItems": 1,
471
+ "items": { "$ref": "#/definitions/schema" }
472
+ }
473
+ ],
474
+ "default": { }
475
+ },
476
+ "maxItems": { "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger" },
477
+ "minItems": { "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0" },
478
+ "uniqueItems": { "$ref": "http://json-schema.org/draft-04/schema#/properties/uniqueItems" },
479
+ "maxProperties": { "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger" },
480
+ "minProperties": { "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0" },
481
+ "required": { "$ref": "http://json-schema.org/draft-04/schema#/definitions/stringArray" },
482
+ "externalDocs": { "$ref": "#/definitions/externalDocs" },
483
+ "properties": {
484
+ "type": "object",
485
+ "additionalProperties": { "$ref": "#/definitions/schema" },
486
+ "default": { }
487
+ },
488
+ "enum": { "$ref": "http://json-schema.org/draft-04/schema#/properties/enum" },
489
+ "type": { "$ref": "http://json-schema.org/draft-04/schema#/properties/type" },
490
+ "example": {
491
+
492
+ },
493
+ "allOf": {
494
+ "type": "array",
495
+ "minItems": 1,
496
+ "items": { "$ref": "#/definitions/schema" }
497
+ }
498
+ }
499
+ },
500
+ "security": {
501
+ "description": "defines security definitions"
502
+ },
503
+ "securityRequirement": {
504
+ "description": "defines a security requirement",
505
+ "type": "array"
506
+ },
507
+ "xml": {
508
+ "properties": {
509
+ "name": { "type": "string"},
510
+ "namespace": { "type": "string" },
511
+ "prefix": { "type": "string" },
512
+ "attribute": { "type": "boolean" },
513
+ "wrapped": { "type": "boolean" }
514
+ },
515
+ "additionalProperties": false
516
+ },
517
+ "tag": {
518
+ "type": "object",
519
+ "properties": {
520
+ "externalDocs": { "$ref": "#/definitions/externalDocs" }
521
+ },
522
+ "patternProperties": {
523
+ "^x-": {
524
+ "$ref": "#/definitions/vendorExtension"
525
+ },
526
+ "^/.*[^\/]$": {
527
+ "type": "string"
528
+ }
529
+ }
530
+ }
531
+ }
532
+ }