swagger_yard 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/swagger_yard/api_declaration.rb +2 -1
- data/lib/swagger_yard/operation.rb +14 -3
- data/lib/swagger_yard/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbaa9b5d7d53b11b910f876553fba88c5b7aa906
|
4
|
+
data.tar.gz: e784d091c73324be6644fba2c711663645758713
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0321da037d482c008f53b75b7db60bc0d8db507faefb46b4e8853654d49d0c45f0182fbc0fbdabaeeec08b6457d787e9909114992a995311670907d28645419
|
7
|
+
data.tar.gz: e8b9724266bfdf98d7bdaab4963695cea48833754dcbd0e0bc524dc74889ea091d69e39468dbbff0743144084db9b4165a530e15477d656399811025f42bcc4b
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module SwaggerYard
|
2
2
|
class ApiDeclaration
|
3
3
|
attr_accessor :description, :resource
|
4
|
-
attr_reader :apis, :authorizations
|
4
|
+
attr_reader :apis, :authorizations, :class_name
|
5
5
|
|
6
6
|
def self.from_yard_object(yard_object)
|
7
7
|
new.add_yard_object(yard_object)
|
@@ -34,6 +34,7 @@ module SwaggerYard
|
|
34
34
|
|
35
35
|
def add_info(yard_object)
|
36
36
|
@description = yard_object.docstring
|
37
|
+
@class_name = yard_object.path
|
37
38
|
|
38
39
|
if tag = yard_object.tags.detect {|t| t.tag_name == "resource"}
|
39
40
|
@resource = tag.text
|
@@ -59,19 +59,30 @@ module SwaggerYard
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
+
api_decl = @api.api_declaration
|
63
|
+
|
62
64
|
{
|
63
|
-
"tags" => [
|
64
|
-
"operationId" => "#{
|
65
|
+
"tags" => [api_decl.resource].compact,
|
66
|
+
"operationId" => "#{api_decl.resource}-#{ruby_method}",
|
65
67
|
"parameters" => params,
|
66
68
|
"responses" => responses,
|
67
69
|
}.tap do |h|
|
68
70
|
h["description"] = description unless description.empty?
|
69
71
|
h["summary"] = summary unless summary.empty?
|
70
72
|
|
71
|
-
authorizations =
|
73
|
+
authorizations = api_decl.authorizations
|
72
74
|
unless authorizations.empty?
|
73
75
|
h["security"] = authorizations.map {|k,v| { k => v} }
|
74
76
|
end
|
77
|
+
|
78
|
+
# Rails controller/action: if constantize/controller_path methods are
|
79
|
+
# unavailable or constant is not defined, catch exception and skip these
|
80
|
+
# attributes.
|
81
|
+
begin
|
82
|
+
h["x-controller"] = api_decl.class_name.constantize.controller_path
|
83
|
+
h["x-action"] = ruby_method
|
84
|
+
rescue NameError, NoMethodError
|
85
|
+
end
|
75
86
|
end
|
76
87
|
end
|
77
88
|
|
data/lib/swagger_yard/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swagger_yard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chtrinh (Chris Trinh)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yard
|