swagger_yard 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6166455641c33ed4e8dd620e1d9fd6d7a7a04a8
4
- data.tar.gz: 3a36d52baa856e2d06acfc04da5c4a19403aeebf
3
+ metadata.gz: fbaa9b5d7d53b11b910f876553fba88c5b7aa906
4
+ data.tar.gz: e784d091c73324be6644fba2c711663645758713
5
5
  SHA512:
6
- metadata.gz: fe018dd6c2336f4b5ccd2b144b54a578e6f7a574a603ee67d0f40b973ed00e41dd7a52b7572666dacd37464e24df6897453d238e7ca986ae7b5ab9441bc68169
7
- data.tar.gz: 903a6787f86dea465e460b83212546aa67ca60b49287779b982a042af3e9f9379184f78af034b6ba760baa33ef81d9fc135df3056318bff3f1de6e02c5b58df9
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" => [@api.api_declaration.resource].compact,
64
- "operationId" => "#{@api.api_declaration.resource}-#{ruby_method}",
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 = @api.api_declaration.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
 
@@ -1,3 +1,3 @@
1
1
  module SwaggerYard
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
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.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-25 00:00:00.000000000 Z
11
+ date: 2016-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard