swagger_parser 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/swagger_parser/operation.rb +9 -0
- data/lib/swagger_parser/path.rb +24 -7
- data/lib/swagger_parser/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b25b8b773325fefdff2ca3b99e2315f7aee9dd0
|
4
|
+
data.tar.gz: 54d3c5035f3a85591452d714270ce4250ee961a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 927bbe33a8ea50822ccd596c59f5a31b9575cd4754a0f063e87f932c90ba869ae5d275888de4599eb1f6d2bb5f5d9599952dbcc3a97bb5821de7beec7f3b93eb
|
7
|
+
data.tar.gz: 8f3ef79d29675b5aa1af4e63b4933f9fceb7044b4ff0d6c97d9046c6eb5f2d84ec63ee5ce902cbd96ae5630a7435d36e3959a7163c377575c086549f2eb24b25
|
data/CHANGELOG.md
ADDED
@@ -9,6 +9,15 @@ module SwaggerParser
|
|
9
9
|
include SwaggerParser::Extendable
|
10
10
|
include SwaggerParser::ExternalDocsAttributable
|
11
11
|
|
12
|
+
attr_reader :http_method
|
13
|
+
|
14
|
+
# @param [String] http_method
|
15
|
+
# @param [Object] source
|
16
|
+
def initialize(source, http_method:)
|
17
|
+
super(source)
|
18
|
+
@http_method = http_method
|
19
|
+
end
|
20
|
+
|
12
21
|
# @return [Object]
|
13
22
|
def consumes
|
14
23
|
source["consumes"] || []
|
data/lib/swagger_parser/path.rb
CHANGED
@@ -5,34 +5,51 @@ require "swagger_parser/source_based_object"
|
|
5
5
|
|
6
6
|
module SwaggerParser
|
7
7
|
class Path < SourceBasedObject
|
8
|
+
OPERATION_NAMES = %w(
|
9
|
+
delete
|
10
|
+
get
|
11
|
+
head
|
12
|
+
options
|
13
|
+
patch
|
14
|
+
post
|
15
|
+
put
|
16
|
+
)
|
17
|
+
|
8
18
|
include SwaggerParser::Extendable
|
9
19
|
include SwaggerParser::Referable
|
10
20
|
|
11
21
|
# @return [SwaggerParser::Operation, nil]
|
12
22
|
def delete
|
13
23
|
if source["delete"]
|
14
|
-
SwaggerParser::Operation.new(source["delete"])
|
24
|
+
SwaggerParser::Operation.new(source["delete"], http_method: "DELETE")
|
15
25
|
end
|
16
26
|
end
|
17
27
|
|
18
28
|
# @return [SwaggerParser::Operation, nil]
|
19
29
|
def get
|
20
30
|
if source["get"]
|
21
|
-
SwaggerParser::Operation.new(source["get"])
|
31
|
+
SwaggerParser::Operation.new(source["get"], http_method: "GET")
|
22
32
|
end
|
23
33
|
end
|
24
34
|
|
25
35
|
# @return [SwaggerParser::Operation, nil]
|
26
36
|
def head
|
27
37
|
if source["head"]
|
28
|
-
SwaggerParser::Operation.new(source["head"])
|
38
|
+
SwaggerParser::Operation.new(source["head"], http_method: "HEAD")
|
29
39
|
end
|
30
40
|
end
|
31
41
|
|
42
|
+
# @return [Array<SwaggerParser::Operation>]
|
43
|
+
def operations
|
44
|
+
OPERATION_NAMES.map do |operation_name|
|
45
|
+
send(operation_name)
|
46
|
+
end.compact
|
47
|
+
end
|
48
|
+
|
32
49
|
# @return [SwaggerParser::Operation, nil]
|
33
50
|
def options
|
34
51
|
if source["options"]
|
35
|
-
SwaggerParser::Operation.new(source["options"])
|
52
|
+
SwaggerParser::Operation.new(source["options"], http_method: "OPTIONS")
|
36
53
|
end
|
37
54
|
end
|
38
55
|
|
@@ -44,21 +61,21 @@ module SwaggerParser
|
|
44
61
|
# @return [SwaggerParser::Operation, nil]
|
45
62
|
def patch
|
46
63
|
if source["patch"]
|
47
|
-
SwaggerParser::Operation.new(source["patch"])
|
64
|
+
SwaggerParser::Operation.new(source["patch"], http_method: "PATCH")
|
48
65
|
end
|
49
66
|
end
|
50
67
|
|
51
68
|
# @return [SwaggerParser::Operation, nil]
|
52
69
|
def post
|
53
70
|
if source["post"]
|
54
|
-
SwaggerParser::Operation.new(source["post"])
|
71
|
+
SwaggerParser::Operation.new(source["post"], http_method: "POST")
|
55
72
|
end
|
56
73
|
end
|
57
74
|
|
58
75
|
# @return [SwaggerParser::Operation, nil]
|
59
76
|
def put
|
60
77
|
if source["put"]
|
61
|
-
SwaggerParser::Operation.new(source["put"])
|
78
|
+
SwaggerParser::Operation.new(source["put"], http_method: "PUT")
|
62
79
|
end
|
63
80
|
end
|
64
81
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swagger_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- ".gitignore"
|
63
63
|
- ".rspec"
|
64
64
|
- ".travis.yml"
|
65
|
+
- CHANGELOG.md
|
65
66
|
- Gemfile
|
66
67
|
- LICENSE.txt
|
67
68
|
- README.md
|