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.
- checksums.yaml +7 -0
- data/.rspec +1 -0
- data/.rubocop.yml +2 -0
- data/.yardopts +4 -0
- data/Gemfile +1 -0
- data/README.md +87 -4
- data/Rakefile +4 -1
- data/lib/swagger.rb +30 -6
- data/lib/swagger/{api_declaration.rb → api.rb} +4 -3
- data/lib/swagger/attachable.rb +8 -5
- data/lib/swagger/builder.rb +24 -2
- data/lib/swagger/mime_type.rb +20 -0
- data/lib/swagger/parsers.rb +38 -0
- data/lib/swagger/schema.rb +3 -0
- data/lib/swagger/swagger_object.rb +42 -0
- data/lib/swagger/uri.rb +2 -1
- data/lib/swagger/uri_template.rb +3 -2
- data/lib/swagger/v2/api.rb +89 -0
- data/lib/swagger/v2/example.rb +11 -3
- data/lib/swagger/v2/info.rb +24 -14
- data/lib/swagger/v2/operation.rb +52 -0
- data/lib/swagger/v2/parameter.rb +40 -1
- data/lib/swagger/v2/path.rb +7 -6
- data/lib/swagger/v2/response.rb +9 -5
- data/lib/swagger/v2/tag.rb +11 -0
- data/lib/swagger/version.rb +1 -1
- data/resources/schemas/swagger/v2.0/schema.json +2 -2
- data/spec/swagger/{api_declaration_spec.rb → api_spec.rb} +1 -1
- data/spec/swagger/builder_spec.rb +52 -0
- data/spec/swagger/{api_operation_spec.rb → operation_spec.rb} +9 -1
- data/spec/swagger/swagger_spec.rb +50 -1
- data/swagger-core.gemspec +2 -0
- metadata +73 -62
- data/lib/swagger/definition_section.rb +0 -34
- data/lib/swagger/loaders.rb +0 -29
- data/lib/swagger/v2/api_declaration.rb +0 -81
- data/lib/swagger/v2/api_operation.rb +0 -56
@@ -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
|