open_api-loader 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +15 -0
  3. data/.gitignore +13 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +28 -0
  6. data/.travis.yml +24 -0
  7. data/CHANGELOG.md +10 -0
  8. data/Gemfile +8 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +99 -0
  11. data/Rakefile +10 -0
  12. data/bin/console +6 -0
  13. data/bin/setup +6 -0
  14. data/lib/open_api-loader.rb +1 -0
  15. data/lib/open_api/loader.rb +44 -0
  16. data/lib/open_api/loader/collector.rb +61 -0
  17. data/lib/open_api/loader/denormalizer.rb +27 -0
  18. data/lib/open_api/loader/denormalizer/parameters.rb +46 -0
  19. data/lib/open_api/loader/denormalizer/security.rb +35 -0
  20. data/lib/open_api/loader/denormalizer/servers.rb +36 -0
  21. data/lib/open_api/loader/denormalizer/variables.rb +54 -0
  22. data/lib/open_api/loader/reader.rb +47 -0
  23. data/lib/open_api/loader/ref.rb +85 -0
  24. data/lib/open_api/loader/translator.rb +50 -0
  25. data/lib/open_api/loader/translator/clean_definitions.rb +16 -0
  26. data/lib/open_api/loader/translator/convert_bodies.rb +77 -0
  27. data/lib/open_api/loader/translator/convert_forms.rb +71 -0
  28. data/lib/open_api/loader/translator/convert_parameters.rb +135 -0
  29. data/lib/open_api/loader/translator/convert_responses.rb +63 -0
  30. data/lib/open_api/loader/translator/convert_security_schemes.rb +49 -0
  31. data/lib/open_api/loader/translator/convert_servers.rb +46 -0
  32. data/lib/open_api/loader/translator/convert_version.rb +12 -0
  33. data/lib/open_api/loader/translator/denormalize_consumes.rb +44 -0
  34. data/lib/open_api/loader/translator/denormalize_parameters.rb +55 -0
  35. data/lib/open_api/loader/translator/denormalize_produces.rb +53 -0
  36. data/open_api-loader.gemspec +25 -0
  37. data/spec/fixtures/oas2/collected.yaml +1012 -0
  38. data/spec/fixtures/oas2/denormalized.yaml +1462 -0
  39. data/spec/fixtures/oas2/loaded.yaml +564 -0
  40. data/spec/fixtures/oas2/models.yaml +118 -0
  41. data/spec/fixtures/oas2/source.json +1 -0
  42. data/spec/fixtures/oas2/source.yaml +569 -0
  43. data/spec/fixtures/oas2/translated.yaml +1396 -0
  44. data/spec/fixtures/oas3/collected.yaml +233 -0
  45. data/spec/fixtures/oas3/denormalized.yaml +233 -0
  46. data/spec/fixtures/oas3/source.json +1 -0
  47. data/spec/fixtures/oas3/source.yaml +217 -0
  48. data/spec/loader_spec.rb +53 -0
  49. data/spec/spec_helper.rb +17 -0
  50. data/spec/support/fixture_helpers.rb +18 -0
  51. data/spec/support/path_helpers.rb +27 -0
  52. data/spec/unit/collector_spec.rb +31 -0
  53. data/spec/unit/denormalizer_spec.rb +17 -0
  54. data/spec/unit/reader_spec.rb +53 -0
  55. data/spec/unit/ref_spec.rb +107 -0
  56. data/spec/unit/translator_spec.rb +15 -0
  57. metadata +232 -0
@@ -0,0 +1,564 @@
1
+ ---
2
+ swagger: '2.0'
3
+ info:
4
+ description: 'This is a sample server Petstore server. You can find out more about Swagger
5
+ 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
+ consumes:
33
+ - application/json
34
+ - application/xml
35
+ produces:
36
+ - application/xml
37
+ - application/json
38
+ paths:
39
+ "/pet":
40
+ post:
41
+ tags:
42
+ - pet
43
+ summary: Add a new pet to the store
44
+ description: ''
45
+ operationId: addPet
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": models.yaml#/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
+ parameters:
67
+ - in: body
68
+ name: body
69
+ description: Pet object that needs to be added to the store
70
+ required: true
71
+ schema:
72
+ "$ref": models.yaml#/Pet
73
+ responses:
74
+ '400':
75
+ description: Invalid ID supplied
76
+ '404':
77
+ description: Pet not found
78
+ '405':
79
+ description: Validators exception
80
+ security:
81
+ - petstore_auth:
82
+ - write:pets
83
+ - read:pets
84
+ "/pet/findByStatus":
85
+ get:
86
+ tags:
87
+ - pet
88
+ summary: Finds Pets by status
89
+ description: Multiple status values can be provided with comma separated strings
90
+ operationId: findPetsByStatus
91
+ produces:
92
+ - application/xml
93
+ - application/json
94
+ parameters:
95
+ - name: status
96
+ in: query
97
+ description: Status values that need to be considered for filter
98
+ required: true
99
+ type: array
100
+ items:
101
+ type: string
102
+ enum:
103
+ - available
104
+ - pending
105
+ - sold
106
+ default: available
107
+ collectionFormat: multi
108
+ responses:
109
+ '200':
110
+ description: successful operation
111
+ schema:
112
+ type: array
113
+ items:
114
+ "$ref": models.yaml#/Pet
115
+ '400':
116
+ description: Invalid status value
117
+ security:
118
+ - petstore_auth:
119
+ - write:pets
120
+ - read:pets
121
+ "/pet/findByTags":
122
+ get:
123
+ tags:
124
+ - pet
125
+ summary: Finds Pets by tags
126
+ description: Muliple tags can be provided with comma separated strings. Use tag1,
127
+ tag2, tag3 for testing.
128
+ operationId: findPetsByTags
129
+ produces:
130
+ - application/xml
131
+ - application/json
132
+ parameters:
133
+ - name: tags
134
+ in: query
135
+ description: Tags to filter by
136
+ required: true
137
+ type: array
138
+ items:
139
+ type: string
140
+ collectionFormat: multi
141
+ responses:
142
+ '200':
143
+ description: successful operation
144
+ schema:
145
+ type: array
146
+ items:
147
+ "$ref": models.yaml#/Pet
148
+ '400':
149
+ description: Invalid tag value
150
+ security:
151
+ - petstore_auth:
152
+ - write:pets
153
+ - read:pets
154
+ deprecated: true
155
+ "/pet/{petId}":
156
+ parameters:
157
+ - name: petId
158
+ in: path
159
+ description: ID of pet
160
+ required: true
161
+ type: integer
162
+ format: int64
163
+ get:
164
+ tags:
165
+ - pet
166
+ summary: Find pet by ID
167
+ description: Returns a single pet
168
+ operationId: getPetById
169
+ produces:
170
+ - application/xml
171
+ - application/json
172
+ responses:
173
+ '200':
174
+ description: successful operation
175
+ schema:
176
+ "$ref": models.yaml#/Pet
177
+ '400':
178
+ description: Invalid ID supplied
179
+ '404':
180
+ description: Pet not found
181
+ security:
182
+ - api_key: []
183
+ post:
184
+ tags:
185
+ - pet
186
+ summary: Updates a pet in the store with form data
187
+ description: ''
188
+ operationId: updatePetWithForm
189
+ consumes:
190
+ - application/x-www-form-urlencoded
191
+ parameters:
192
+ - name: name
193
+ in: formData
194
+ description: Updated name of the pet
195
+ required: false
196
+ type: string
197
+ - name: status
198
+ in: formData
199
+ description: Updated status of the pet
200
+ required: false
201
+ type: string
202
+ responses:
203
+ '405':
204
+ description: Invalid input
205
+ security:
206
+ - petstore_auth:
207
+ - write:pets
208
+ - read:pets
209
+ delete:
210
+ tags:
211
+ - pet
212
+ summary: Deletes a pet
213
+ description: ''
214
+ operationId: deletePet
215
+ produces:
216
+ - application/xml
217
+ - application/json
218
+ parameters:
219
+ - name: api_key
220
+ in: header
221
+ required: false
222
+ type: string
223
+ responses:
224
+ '400':
225
+ description: Invalid ID supplied
226
+ '404':
227
+ description: Pet not found
228
+ security:
229
+ - petstore_auth:
230
+ - write:pets
231
+ - read:pets
232
+ "/pet/{petId}/uploadImage":
233
+ parameters:
234
+ - name: petId
235
+ in: path
236
+ description: ID of pet
237
+ required: true
238
+ type: integer
239
+ format: int64
240
+ post:
241
+ tags:
242
+ - pet
243
+ summary: uploads an image
244
+ description: ''
245
+ operationId: uploadFile
246
+ consumes:
247
+ - multipart/form-data
248
+ produces:
249
+ - application/json
250
+ parameters:
251
+ - name: additionalMetadata
252
+ in: formData
253
+ description: Additional data to pass to server
254
+ required: false
255
+ type: string
256
+ - name: file
257
+ in: formData
258
+ description: file to upload
259
+ required: false
260
+ type: file
261
+ responses:
262
+ '200':
263
+ description: successful operation
264
+ schema:
265
+ "$ref": "#/definitions/ApiResponse"
266
+ security:
267
+ - petstore_auth:
268
+ - write:pets
269
+ - read:pets
270
+ "/store/inventory":
271
+ get:
272
+ tags:
273
+ - store
274
+ summary: Returns pet inventories by status
275
+ description: Returns a map of status codes to quantities
276
+ operationId: getInventory
277
+ produces:
278
+ - application/json
279
+ parameters: []
280
+ responses:
281
+ '200':
282
+ description: successful operation
283
+ schema:
284
+ type: object
285
+ additionalProperties:
286
+ type: integer
287
+ format: int32
288
+ security:
289
+ - api_key: []
290
+ "/store/order":
291
+ post:
292
+ tags:
293
+ - store
294
+ summary: Place an order for a pet
295
+ description: ''
296
+ operationId: placeOrder
297
+ produces:
298
+ - application/xml
299
+ - application/json
300
+ parameters:
301
+ - in: body
302
+ name: body
303
+ description: order placed for purchasing the pet
304
+ required: true
305
+ schema:
306
+ "$ref": models.yaml#/Order
307
+ responses:
308
+ '200':
309
+ description: successful operation
310
+ schema:
311
+ "$ref": models.yaml#/Order
312
+ '400':
313
+ description: Invalid Order
314
+ "/store/order/{orderId}":
315
+ parameters:
316
+ - name: "orderId"
317
+ in: "path"
318
+ description: ID of purchase order
319
+ required: true
320
+ type: "integer"
321
+ maximum: 10.0
322
+ minimum: 1.0
323
+ format: "int64"
324
+ get:
325
+ tags:
326
+ - store
327
+ summary: Find purchase order by ID
328
+ description: For valid response try integer IDs with value >= 1 and <= 10. Other
329
+ values will generated exceptions
330
+ operationId: getOrderById
331
+ produces:
332
+ - application/xml
333
+ - application/json
334
+ responses:
335
+ '200':
336
+ description: successful operation
337
+ schema:
338
+ "$ref": models.yaml#/Order
339
+ '400':
340
+ description: Invalid ID supplied
341
+ '404':
342
+ description: Order not found
343
+ delete:
344
+ tags:
345
+ - store
346
+ summary: Delete purchase order by ID
347
+ description: For valid response try integer IDs with positive integer value. Negative
348
+ or non-integer values will generate API errors
349
+ operationId: deleteOrder
350
+ produces:
351
+ - application/xml
352
+ - application/json
353
+ responses:
354
+ '400':
355
+ description: Invalid ID supplied
356
+ '404':
357
+ description: Order not found
358
+ "/user":
359
+ post:
360
+ tags:
361
+ - user
362
+ summary: Create user
363
+ description: This can only be done by the logged in user.
364
+ operationId: createUser
365
+ produces:
366
+ - application/xml
367
+ - application/json
368
+ parameters:
369
+ - in: body
370
+ name: body
371
+ description: Created user object
372
+ required: true
373
+ schema:
374
+ "$ref": models.yaml#/User
375
+ responses:
376
+ default:
377
+ description: successful operation
378
+ "/user/createWithArray":
379
+ post:
380
+ tags:
381
+ - user
382
+ summary: Creates list of users with given input array
383
+ description: ''
384
+ operationId: createUsersWithArrayInput
385
+ produces:
386
+ - application/xml
387
+ - application/json
388
+ parameters:
389
+ - in: body
390
+ name: body
391
+ description: List of user object
392
+ required: true
393
+ schema:
394
+ type: array
395
+ items:
396
+ "$ref": models.yaml#/User
397
+ responses:
398
+ default:
399
+ description: successful operation
400
+ "/user/createWithList":
401
+ post:
402
+ tags:
403
+ - user
404
+ summary: Creates list of users with given input array
405
+ description: ''
406
+ operationId: createUsersWithListInput
407
+ produces:
408
+ - application/xml
409
+ - application/json
410
+ parameters:
411
+ - in: body
412
+ name: body
413
+ description: List of user object
414
+ required: true
415
+ schema:
416
+ type: array
417
+ items:
418
+ "$ref": models.yaml#/User
419
+ responses:
420
+ default:
421
+ description: successful operation
422
+ "/user/login":
423
+ get:
424
+ tags:
425
+ - user
426
+ summary: Logs user into the system
427
+ description: ''
428
+ operationId: loginUser
429
+ produces:
430
+ - application/xml
431
+ - application/json
432
+ parameters:
433
+ - name: username
434
+ in: query
435
+ description: The user name for login
436
+ required: true
437
+ type: string
438
+ - name: password
439
+ in: query
440
+ description: The password for login in clear text
441
+ required: true
442
+ type: string
443
+ responses:
444
+ '200':
445
+ description: successful operation
446
+ schema:
447
+ type: string
448
+ headers:
449
+ X-Rate-Limit:
450
+ type: integer
451
+ format: int32
452
+ description: calls per hour allowed by the user
453
+ X-Expires-After:
454
+ type: string
455
+ format: date-time
456
+ description: date in UTC when token expires
457
+ '400':
458
+ description: Invalid username/password supplied
459
+ "/user/logout":
460
+ get:
461
+ tags:
462
+ - user
463
+ summary: Logs out current logged in user session
464
+ description: ''
465
+ operationId: logoutUser
466
+ produces:
467
+ - application/xml
468
+ - application/json
469
+ parameters: []
470
+ responses:
471
+ default:
472
+ description: successful operation
473
+ "/user/{username}":
474
+ parameters:
475
+ - name: username
476
+ in: path
477
+ description: 'The name of the user. Use user1 for testing. '
478
+ required: true
479
+ type: string
480
+ get:
481
+ tags:
482
+ - user
483
+ summary: Get user by user name
484
+ description: ''
485
+ operationId: getUserByName
486
+ produces:
487
+ - application/xml
488
+ - application/json
489
+ responses:
490
+ '200':
491
+ description: successful operation
492
+ schema:
493
+ "$ref": models.yaml#/User
494
+ '400':
495
+ description: Invalid username supplied
496
+ '404':
497
+ description: User not found
498
+ put:
499
+ tags:
500
+ - user
501
+ summary: Updated user
502
+ description: This can only be done by the logged in user.
503
+ operationId: updateUser
504
+ produces:
505
+ - application/xml
506
+ - application/json
507
+ parameters:
508
+ - in: body
509
+ name: body
510
+ description: Updated user object
511
+ required: true
512
+ schema:
513
+ "$ref": models.yaml#/User
514
+ responses:
515
+ '400':
516
+ description: Invalid user supplied
517
+ '404':
518
+ description: User not found
519
+ delete:
520
+ tags:
521
+ - user
522
+ summary: Delete user
523
+ description: This can only be done by the logged in user.
524
+ operationId: deleteUser
525
+ parameters:
526
+ - name: username
527
+ in: path
528
+ description: 'The name of the user to be deleted. '
529
+ required: true
530
+ type: string
531
+ produces:
532
+ - application/xml
533
+ - application/json
534
+ responses:
535
+ '400':
536
+ description: Invalid username supplied
537
+ '404':
538
+ description: User not found
539
+ securityDefinitions:
540
+ petstore_auth:
541
+ type: oauth2
542
+ authorizationUrl: http://petstore.swagger.io/oauth/dialog
543
+ flow: implicit
544
+ scopes:
545
+ write:pets: modify pets in your account
546
+ read:pets: read your pets
547
+ api_key:
548
+ type: apiKey
549
+ name: api_key
550
+ in: header
551
+ definitions:
552
+ ApiResponse:
553
+ type: object
554
+ properties:
555
+ code:
556
+ type: integer
557
+ format: int32
558
+ type:
559
+ type: string
560
+ message:
561
+ type: string
562
+ externalDocs:
563
+ description: Find out more about Swagger
564
+ url: http://swagger.io