swagger_parser 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +3 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +11 -0
  8. data/Rakefile +1 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +7 -0
  11. data/examples/swagger.json +1038 -0
  12. data/examples/swagger.yml +701 -0
  13. data/lib/swagger_parser/contact.rb +20 -0
  14. data/lib/swagger_parser/definitions.rb +13 -0
  15. data/lib/swagger_parser/enumerable_object.rb +30 -0
  16. data/lib/swagger_parser/errors/base_error.rb +6 -0
  17. data/lib/swagger_parser/errors/file_parsing_error.rb +8 -0
  18. data/lib/swagger_parser/examples.rb +12 -0
  19. data/lib/swagger_parser/extendable.rb +10 -0
  20. data/lib/swagger_parser/external_docs_attributable.rb +12 -0
  21. data/lib/swagger_parser/external_documentation.rb +6 -0
  22. data/lib/swagger_parser/file_parser.rb +58 -0
  23. data/lib/swagger_parser/header.rb +6 -0
  24. data/lib/swagger_parser/headers.rb +13 -0
  25. data/lib/swagger_parser/info.rb +40 -0
  26. data/lib/swagger_parser/items.rb +8 -0
  27. data/lib/swagger_parser/json_schema.rb +23 -0
  28. data/lib/swagger_parser/license.rb +15 -0
  29. data/lib/swagger_parser/minimal_json_schema.rb +91 -0
  30. data/lib/swagger_parser/operation.rb +67 -0
  31. data/lib/swagger_parser/parameter.rb +59 -0
  32. data/lib/swagger_parser/parameters.rb +13 -0
  33. data/lib/swagger_parser/path.rb +65 -0
  34. data/lib/swagger_parser/paths.rb +16 -0
  35. data/lib/swagger_parser/referable.rb +8 -0
  36. data/lib/swagger_parser/reference.rb +8 -0
  37. data/lib/swagger_parser/response.rb +31 -0
  38. data/lib/swagger_parser/response_definitions.rb +13 -0
  39. data/lib/swagger_parser/responses.rb +18 -0
  40. data/lib/swagger_parser/schema.rb +29 -0
  41. data/lib/swagger_parser/scopes.rb +12 -0
  42. data/lib/swagger_parser/security.rb +12 -0
  43. data/lib/swagger_parser/security_definitions.rb +13 -0
  44. data/lib/swagger_parser/security_scheme.rb +51 -0
  45. data/lib/swagger_parser/source_based_object.rb +10 -0
  46. data/lib/swagger_parser/swagger.rb +112 -0
  47. data/lib/swagger_parser/tag.rb +20 -0
  48. data/lib/swagger_parser/version.rb +3 -0
  49. data/lib/swagger_parser/xml.rb +30 -0
  50. data/lib/swagger_parser.rb +2 -0
  51. data/swagger_parser.gemspec +20 -0
  52. metadata +137 -0
@@ -0,0 +1,701 @@
1
+ ---
2
+ swagger: '2.0'
3
+ info:
4
+ description: 'This is a sample server Petstore server. You can find out more about
5
+ Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For
6
+ this sample, you can use the api key `special-key` to test the authorization filters.'
7
+ version: 1.0.0
8
+ title: Swagger Petstore
9
+ termsOfService: http://swagger.io/terms/
10
+ contact:
11
+ email: apiteam@swagger.io
12
+ license:
13
+ name: Apache 2.0
14
+ url: http://www.apache.org/licenses/LICENSE-2.0.html
15
+ host: petstore.swagger.io
16
+ basePath: "/v2"
17
+ tags:
18
+ - name: pet
19
+ description: Everything about your Pets
20
+ externalDocs:
21
+ description: Find out more
22
+ url: http://swagger.io
23
+ - name: store
24
+ description: Access to Petstore orders
25
+ - name: user
26
+ description: Operations about user
27
+ externalDocs:
28
+ description: Find out more about our store
29
+ url: http://swagger.io
30
+ schemes:
31
+ - http
32
+ paths:
33
+ "/pet":
34
+ post:
35
+ tags:
36
+ - pet
37
+ summary: Add a new pet to the store
38
+ description: ''
39
+ operationId: addPet
40
+ consumes:
41
+ - application/json
42
+ - application/xml
43
+ produces:
44
+ - application/xml
45
+ - application/json
46
+ parameters:
47
+ - in: body
48
+ name: body
49
+ description: Pet object that needs to be added to the store
50
+ required: true
51
+ schema:
52
+ "$ref": "#/definitions/Pet"
53
+ responses:
54
+ '405':
55
+ description: Invalid input
56
+ security:
57
+ - petstore_auth:
58
+ - write:pets
59
+ - read:pets
60
+ put:
61
+ tags:
62
+ - pet
63
+ summary: Update an existing pet
64
+ description: ''
65
+ operationId: updatePet
66
+ consumes:
67
+ - application/json
68
+ - application/xml
69
+ produces:
70
+ - application/xml
71
+ - application/json
72
+ parameters:
73
+ - in: body
74
+ name: body
75
+ description: Pet object that needs to be added to the store
76
+ required: true
77
+ schema:
78
+ "$ref": "#/definitions/Pet"
79
+ responses:
80
+ '400':
81
+ description: Invalid ID supplied
82
+ '404':
83
+ description: Pet not found
84
+ '405':
85
+ description: Validation exception
86
+ security:
87
+ - petstore_auth:
88
+ - write:pets
89
+ - read:pets
90
+ "/pet/findByStatus":
91
+ get:
92
+ tags:
93
+ - pet
94
+ summary: Finds Pets by status
95
+ description: Multiple status values can be provided with comma seperated strings
96
+ operationId: findPetsByStatus
97
+ produces:
98
+ - application/xml
99
+ - application/json
100
+ parameters:
101
+ - name: status
102
+ in: query
103
+ description: Status values that need to be considered for filter
104
+ required: true
105
+ type: array
106
+ items:
107
+ type: string
108
+ enum:
109
+ - available
110
+ - pending
111
+ - sold
112
+ default: available
113
+ collectionFormat: csv
114
+ responses:
115
+ '200':
116
+ description: successful operation
117
+ schema:
118
+ type: array
119
+ items:
120
+ "$ref": "#/definitions/Pet"
121
+ '400':
122
+ description: Invalid status value
123
+ security:
124
+ - petstore_auth:
125
+ - write:pets
126
+ - read:pets
127
+ "/pet/findByTags":
128
+ get:
129
+ tags:
130
+ - pet
131
+ summary: Finds Pets by tags
132
+ description: Muliple tags can be provided with comma seperated strings. Use
133
+ tag1, tag2, tag3 for testing.
134
+ operationId: findPetsByTags
135
+ produces:
136
+ - application/xml
137
+ - application/json
138
+ parameters:
139
+ - name: tags
140
+ in: query
141
+ description: Tags to filter by
142
+ required: true
143
+ type: array
144
+ items:
145
+ type: string
146
+ collectionFormat: csv
147
+ responses:
148
+ '200':
149
+ description: successful operation
150
+ schema:
151
+ type: array
152
+ items:
153
+ "$ref": "#/definitions/Pet"
154
+ '400':
155
+ description: Invalid tag value
156
+ security:
157
+ - petstore_auth:
158
+ - write:pets
159
+ - read:pets
160
+ "/pet/{petId}":
161
+ get:
162
+ tags:
163
+ - pet
164
+ summary: Find pet by ID
165
+ description: Returns a single pet
166
+ operationId: getPetById
167
+ produces:
168
+ - application/xml
169
+ - application/json
170
+ parameters:
171
+ - name: petId
172
+ in: path
173
+ description: ID of pet to return
174
+ required: true
175
+ type: integer
176
+ format: int64
177
+ responses:
178
+ '200':
179
+ description: successful operation
180
+ schema:
181
+ "$ref": "#/definitions/Pet"
182
+ '400':
183
+ description: Invalid ID supplied
184
+ '404':
185
+ description: Pet not found
186
+ security:
187
+ - api_key: []
188
+ post:
189
+ tags:
190
+ - pet
191
+ summary: Updates a pet in the store with form data
192
+ description: ''
193
+ operationId: updatePetWithForm
194
+ consumes:
195
+ - application/x-www-form-urlencoded
196
+ produces:
197
+ - application/xml
198
+ - application/json
199
+ parameters:
200
+ - name: petId
201
+ in: path
202
+ description: ID of pet that needs to be updated
203
+ required: true
204
+ type: integer
205
+ format: int64
206
+ - name: name
207
+ in: formData
208
+ description: Updated name of the pet
209
+ required: false
210
+ type: string
211
+ - name: status
212
+ in: formData
213
+ description: Updated status of the pet
214
+ required: false
215
+ type: string
216
+ responses:
217
+ '405':
218
+ description: Invalid input
219
+ security:
220
+ - petstore_auth:
221
+ - write:pets
222
+ - read:pets
223
+ delete:
224
+ tags:
225
+ - pet
226
+ summary: Deletes a pet
227
+ description: ''
228
+ operationId: deletePet
229
+ produces:
230
+ - application/xml
231
+ - application/json
232
+ parameters:
233
+ - name: api_key
234
+ in: header
235
+ required: false
236
+ type: string
237
+ - name: petId
238
+ in: path
239
+ description: Pet id to delete
240
+ required: true
241
+ type: integer
242
+ format: int64
243
+ responses:
244
+ '400':
245
+ description: Invalid pet value
246
+ security:
247
+ - petstore_auth:
248
+ - write:pets
249
+ - read:pets
250
+ "/pet/{petId}/uploadImage":
251
+ post:
252
+ tags:
253
+ - pet
254
+ summary: uploads an image
255
+ description: ''
256
+ operationId: uploadFile
257
+ consumes:
258
+ - multipart/form-data
259
+ produces:
260
+ - application/json
261
+ parameters:
262
+ - name: petId
263
+ in: path
264
+ description: ID of pet to update
265
+ required: true
266
+ type: integer
267
+ format: int64
268
+ - name: additionalMetadata
269
+ in: formData
270
+ description: Additional data to pass to server
271
+ required: false
272
+ type: string
273
+ - name: file
274
+ in: formData
275
+ description: file to upload
276
+ required: false
277
+ type: file
278
+ responses:
279
+ '200':
280
+ description: successful operation
281
+ schema:
282
+ "$ref": "#/definitions/ApiResponse"
283
+ security:
284
+ - petstore_auth:
285
+ - write:pets
286
+ - read:pets
287
+ "/store/inventory":
288
+ get:
289
+ tags:
290
+ - store
291
+ summary: Returns pet inventories by status
292
+ description: Returns a map of status codes to quantities
293
+ operationId: getInventory
294
+ produces:
295
+ - application/json
296
+ parameters: []
297
+ responses:
298
+ '200':
299
+ description: successful operation
300
+ schema:
301
+ type: object
302
+ additionalProperties:
303
+ type: integer
304
+ format: int32
305
+ security:
306
+ - api_key: []
307
+ "/store/order":
308
+ post:
309
+ tags:
310
+ - store
311
+ summary: Place an order for a pet
312
+ description: ''
313
+ operationId: placeOrder
314
+ produces:
315
+ - application/xml
316
+ - application/json
317
+ parameters:
318
+ - in: body
319
+ name: body
320
+ description: order placed for purchasing the pet
321
+ required: true
322
+ schema:
323
+ "$ref": "#/definitions/Order"
324
+ responses:
325
+ '200':
326
+ description: successful operation
327
+ schema:
328
+ "$ref": "#/definitions/Order"
329
+ '400':
330
+ description: Invalid Order
331
+ "/store/order/{orderId}":
332
+ get:
333
+ tags:
334
+ - store
335
+ summary: Find purchase order by ID
336
+ description: For valid response try integer IDs with value <= 5 or > 10. Other
337
+ values will generated exceptions
338
+ operationId: getOrderById
339
+ produces:
340
+ - application/xml
341
+ - application/json
342
+ parameters:
343
+ - name: orderId
344
+ in: path
345
+ description: ID of pet that needs to be fetched
346
+ required: true
347
+ type: integer
348
+ maximum: 5.0
349
+ minimum: 1.0
350
+ format: int64
351
+ responses:
352
+ '200':
353
+ description: successful operation
354
+ schema:
355
+ "$ref": "#/definitions/Order"
356
+ '400':
357
+ description: Invalid ID supplied
358
+ '404':
359
+ description: Order not found
360
+ delete:
361
+ tags:
362
+ - store
363
+ summary: Delete purchase order by ID
364
+ description: For valid response try integer IDs with value < 1000. Anything
365
+ above 1000 or nonintegers will generate API errors
366
+ operationId: deleteOrder
367
+ produces:
368
+ - application/xml
369
+ - application/json
370
+ parameters:
371
+ - name: orderId
372
+ in: path
373
+ description: ID of the order that needs to be deleted
374
+ required: true
375
+ type: string
376
+ minimum: 1.0
377
+ responses:
378
+ '400':
379
+ description: Invalid ID supplied
380
+ '404':
381
+ description: Order not found
382
+ "/user":
383
+ post:
384
+ tags:
385
+ - user
386
+ summary: Create user
387
+ description: This can only be done by the logged in user.
388
+ operationId: createUser
389
+ produces:
390
+ - application/xml
391
+ - application/json
392
+ parameters:
393
+ - in: body
394
+ name: body
395
+ description: Created user object
396
+ required: true
397
+ schema:
398
+ "$ref": "#/definitions/User"
399
+ responses:
400
+ default:
401
+ description: successful operation
402
+ "/user/createWithArray":
403
+ post:
404
+ tags:
405
+ - user
406
+ summary: Creates list of users with given input array
407
+ description: ''
408
+ operationId: createUsersWithArrayInput
409
+ produces:
410
+ - application/xml
411
+ - application/json
412
+ parameters:
413
+ - in: body
414
+ name: body
415
+ description: List of user object
416
+ required: true
417
+ schema:
418
+ type: array
419
+ items:
420
+ "$ref": "#/definitions/User"
421
+ responses:
422
+ default:
423
+ description: successful operation
424
+ "/user/createWithList":
425
+ post:
426
+ tags:
427
+ - user
428
+ summary: Creates list of users with given input array
429
+ description: ''
430
+ operationId: createUsersWithListInput
431
+ produces:
432
+ - application/xml
433
+ - application/json
434
+ parameters:
435
+ - in: body
436
+ name: body
437
+ description: List of user object
438
+ required: true
439
+ schema:
440
+ type: array
441
+ items:
442
+ "$ref": "#/definitions/User"
443
+ responses:
444
+ default:
445
+ description: successful operation
446
+ "/user/login":
447
+ get:
448
+ tags:
449
+ - user
450
+ summary: Logs user into the system
451
+ description: ''
452
+ operationId: loginUser
453
+ produces:
454
+ - application/xml
455
+ - application/json
456
+ parameters:
457
+ - name: username
458
+ in: query
459
+ description: The user name for login
460
+ required: true
461
+ type: string
462
+ - name: password
463
+ in: query
464
+ description: The password for login in clear text
465
+ required: true
466
+ type: string
467
+ responses:
468
+ '200':
469
+ description: successful operation
470
+ schema:
471
+ type: string
472
+ headers:
473
+ X-Rate-Limit:
474
+ type: integer
475
+ format: int32
476
+ description: calls per hour allowed by the user
477
+ X-Expires-After:
478
+ type: string
479
+ format: date-time
480
+ description: date in UTC when toekn expires
481
+ '400':
482
+ description: Invalid username/password supplied
483
+ "/user/logout":
484
+ get:
485
+ tags:
486
+ - user
487
+ summary: Logs out current logged in user session
488
+ description: ''
489
+ operationId: logoutUser
490
+ produces:
491
+ - application/xml
492
+ - application/json
493
+ parameters: []
494
+ responses:
495
+ default:
496
+ description: successful operation
497
+ "/user/{username}":
498
+ get:
499
+ tags:
500
+ - user
501
+ summary: Get user by user name
502
+ description: ''
503
+ operationId: getUserByName
504
+ produces:
505
+ - application/xml
506
+ - application/json
507
+ parameters:
508
+ - name: username
509
+ in: path
510
+ description: 'The name that needs to be fetched. Use user1 for testing. '
511
+ required: true
512
+ type: string
513
+ responses:
514
+ '200':
515
+ description: successful operation
516
+ schema:
517
+ "$ref": "#/definitions/User"
518
+ '400':
519
+ description: Invalid username supplied
520
+ '404':
521
+ description: User not found
522
+ put:
523
+ tags:
524
+ - user
525
+ summary: Updated user
526
+ description: This can only be done by the logged in user.
527
+ operationId: updateUser
528
+ produces:
529
+ - application/xml
530
+ - application/json
531
+ parameters:
532
+ - name: username
533
+ in: path
534
+ description: name that need to be deleted
535
+ required: true
536
+ type: string
537
+ - in: body
538
+ name: body
539
+ description: Updated user object
540
+ required: true
541
+ schema:
542
+ "$ref": "#/definitions/User"
543
+ responses:
544
+ '400':
545
+ description: Invalid user supplied
546
+ '404':
547
+ description: User not found
548
+ delete:
549
+ tags:
550
+ - user
551
+ summary: Delete user
552
+ description: This can only be done by the logged in user.
553
+ operationId: deleteUser
554
+ produces:
555
+ - application/xml
556
+ - application/json
557
+ parameters:
558
+ - name: username
559
+ in: path
560
+ description: The name that needs to be deleted
561
+ required: true
562
+ type: string
563
+ responses:
564
+ '400':
565
+ description: Invalid username supplied
566
+ '404':
567
+ description: User not found
568
+ securityDefinitions:
569
+ petstore_auth:
570
+ type: oauth2
571
+ authorizationUrl: http://petstore.swagger.io/api/oauth/dialog
572
+ flow: implicit
573
+ scopes:
574
+ write:pets: modify pets in your account
575
+ read:pets: read your pets
576
+ api_key:
577
+ type: apiKey
578
+ name: api_key
579
+ in: header
580
+ definitions:
581
+ Order:
582
+ type: object
583
+ properties:
584
+ id:
585
+ type: integer
586
+ format: int64
587
+ petId:
588
+ type: integer
589
+ format: int64
590
+ quantity:
591
+ type: integer
592
+ format: int32
593
+ shipDate:
594
+ type: string
595
+ format: date-time
596
+ status:
597
+ type: string
598
+ description: Order Status
599
+ enum:
600
+ - placed
601
+ - approved
602
+ - delivered
603
+ complete:
604
+ type: boolean
605
+ default: false
606
+ xml:
607
+ name: Order
608
+ Category:
609
+ type: object
610
+ properties:
611
+ id:
612
+ type: integer
613
+ format: int64
614
+ name:
615
+ type: string
616
+ xml:
617
+ name: Category
618
+ User:
619
+ type: object
620
+ properties:
621
+ id:
622
+ type: integer
623
+ format: int64
624
+ username:
625
+ type: string
626
+ firstName:
627
+ type: string
628
+ lastName:
629
+ type: string
630
+ email:
631
+ type: string
632
+ password:
633
+ type: string
634
+ phone:
635
+ type: string
636
+ userStatus:
637
+ type: integer
638
+ format: int32
639
+ description: User Status
640
+ xml:
641
+ name: User
642
+ Tag:
643
+ type: object
644
+ properties:
645
+ id:
646
+ type: integer
647
+ format: int64
648
+ name:
649
+ type: string
650
+ xml:
651
+ name: Tag
652
+ ApiResponse:
653
+ type: object
654
+ properties:
655
+ code:
656
+ type: integer
657
+ format: int32
658
+ type:
659
+ type: string
660
+ message:
661
+ type: string
662
+ Pet:
663
+ type: object
664
+ required:
665
+ - name
666
+ - photoUrls
667
+ properties:
668
+ id:
669
+ type: integer
670
+ format: int64
671
+ category:
672
+ "$ref": "#/definitions/Category"
673
+ name:
674
+ type: string
675
+ example: doggie
676
+ photoUrls:
677
+ type: array
678
+ xml:
679
+ name: photoUrl
680
+ wrapped: true
681
+ items:
682
+ type: string
683
+ tags:
684
+ type: array
685
+ xml:
686
+ name: tag
687
+ wrapped: true
688
+ items:
689
+ "$ref": "#/definitions/Tag"
690
+ status:
691
+ type: string
692
+ description: pet status in the store
693
+ enum:
694
+ - available
695
+ - pending
696
+ - sold
697
+ xml:
698
+ name: Pet
699
+ externalDocs:
700
+ description: Find out more about Swagger
701
+ url: http://swagger.io
@@ -0,0 +1,20 @@
1
+ require "swagger_parser/source_based_object"
2
+
3
+ module SwaggerParser
4
+ class Contact < SourceBasedObject
5
+ # @return [Object]
6
+ def email
7
+ source["email"]
8
+ end
9
+
10
+ # @return [Object]
11
+ def name
12
+ source["name"]
13
+ end
14
+
15
+ # @return [Object]
16
+ def url
17
+ source["url"]
18
+ end
19
+ end
20
+ end