swagger-core 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,56 +0,0 @@
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