swagger-docs 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f911cef6a9a1c31b6a3eb7b20a9475708d84b450
4
- data.tar.gz: 7c7561937304375ceacc3738e4fcd68c4b3cc228
3
+ metadata.gz: 8288447cb546d04ee3e791e473f06351c1f9e702
4
+ data.tar.gz: cf69d2574759663cdccb895d4c320c0b085fa0e4
5
5
  SHA512:
6
- metadata.gz: 862ec9249db73769611ae420128215e7ac356911cf42983560eb22083f9a8dc11ff9c46c4bbb20daecc09afe613b930dddf18c0bdd0e741b8a4edb21c229c14d
7
- data.tar.gz: 878c2194761ad4d6ce4be794fa782dbb8c2dff643ebd239d368c466090b2f7fe2025cf953c27048a8360c24429896a41a538219f632908cdffdbaea56bd810ef
6
+ metadata.gz: 0cfdeb3b6ffc0c27f2306739d7831496c65c480efd54ad583923b5c0d1a5e6aa12643f55e59ffe4797e71b87f7d29fdba49c8f5d866f167906cc1e113f4be7a1
7
+ data.tar.gz: aa89d0b6b9cac77cd1b9ab5e952b89ce3c85bed99fdc0933e891ba9bcf633180ffc72e6e1ba82e1dfbb197fdb261efafbdc66970f83dbfe474073894716aa6f2
checksums.yaml.gz.sig CHANGED
@@ -1 +1 @@
1
- �����9�4�~�o,�"�W��������(z��6;�:#�x9�ƺ %�h'�_P��u�����[V �'��jA~}��؟�_��Wq��QEIfQa�\�1ߛ���Z���0�}����Aܙ9y^6��v�jCM{|�؂��&����%ddBm���y���-�ۗS��yeW��͞i r~�_-�Y,ط�9 ;)��H��`[1B���)=�E�s��ř�0k��
1
+ 0�zQ��"Hr����B�I9��PJ����|�.�(�7��ȟ�TzH���rt4��~3��1�,��25�F��1��By}e����kUvq�����w�Μ�����\.#뫷��1d�Y�P_t�2}��wa�\�4B2��l\�d�:Mg4C���-�&a\�T��r.�)����z��Z�Ԙ>���dP�|� mBTX W��C"cd
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -38,7 +38,7 @@ Create an initializer in config/initializers (e.g. swagger_docs.rb) and define y
38
38
 
39
39
  ```
40
40
  Swagger::Docs::Config.register_apis({
41
- "1.0" => {:controller_base_path => "api/v1", :api_file_path => "public/api/v1/"}
41
+ "1.0" => {:controller_base_path => "api/v1", :api_file_path => "public/api/v1/", :base_path => "http://api.somedomain.com"}
42
42
  })
43
43
  ```
44
44
 
@@ -45,18 +45,19 @@ module Swagger
45
45
  end
46
46
 
47
47
  def write_doc(api_version, config)
48
- base_path = config[:controller_base_path]
48
+ base_path = config[:base_path]
49
+ controller_base_path = config[:controller_base_path]
49
50
  api_file_path = config[:api_file_path]
50
51
  results = {:processed => [], :skipped => []}
51
52
 
52
53
  FileUtils.mkdir_p(api_file_path) # recursively create out output path
53
54
  Dir.foreach(api_file_path) {|f| fn = File.join(api_file_path, f); File.delete(fn) if !File.directory?(fn)} # clean output path
54
55
 
55
- header = { :api_version => api_version, :swagger_version => "1.2", :base_path => "/#{base_path}"}
56
+ header = { :api_version => api_version, :swagger_version => "1.2", :base_path => "#{base_path}/#{controller_base_path}"}
56
57
  resources = header.merge({:apis => []})
57
58
 
58
59
  paths = Rails.application.routes.routes.map{|i| "#{i.defaults[:controller]}" }
59
- paths = paths.uniq.select{|i| i.start_with?(base_path)}
60
+ paths = paths.uniq.select{|i| i.start_with?(controller_base_path)}
60
61
  paths.each do |path|
61
62
  klass = "#{path.to_s.camelize}Controller".constantize
62
63
  if !klass.methods.include?(:swagger_config) or !klass.swagger_config[:controller]
@@ -71,7 +72,7 @@ module Swagger
71
72
  operations = Hash[operations.map {|k, v| [k.to_s.gsub("@","").to_sym, v] }] # rename :@instance hash keys
72
73
  operations[:method] = verb
73
74
  operations[:nickname] = "#{path.camelize}##{action}"
74
- apis << {:path => get_api_path(route.path.spec).gsub("/#{base_path}",""), :operations => [operations]}
75
+ apis << {:path => get_api_path(route.path.spec).gsub("/#{controller_base_path}",""), :operations => [operations]}
75
76
  end
76
77
  demod = "#{path.to_s.camelize}".demodulize.camelize.underscore
77
78
  resource = header.merge({:resource_path => "/#{demod}", :apis => apis})
@@ -1,5 +1,5 @@
1
1
  module Swagger
2
2
  module Docs
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -23,7 +23,7 @@ describe Swagger::Docs::Generator do
23
23
  stub_route("^DELETE$", "destroy", "api/v1/sample", "/api/v1/sample/:id(.:format)")
24
24
  ]
25
25
  @config = Swagger::Docs::Config.register_apis({
26
- "1.0" => {:controller_base_path => "api/v1", :api_file_path => "#{TMP_DIR}api/v1/"}
26
+ "1.0" => {:controller_base_path => "api/v1", :api_file_path => "#{TMP_DIR}api/v1/", :base_path => "http://api.no.where"}
27
27
  })
28
28
  Rails.stub_chain(:application, :routes, :routes).and_return(routes)
29
29
  Swagger::Docs::Generator.set_real_methods
@@ -65,7 +65,7 @@ describe Swagger::Docs::Generator do
65
65
  expect(response["swaggerVersion"]).to eq "1.2"
66
66
  end
67
67
  it "writes basePath correctly" do
68
- expect(response["basePath"]).to eq "/api/v1"
68
+ expect(response["basePath"]).to eq "http://api.no.where/api/v1"
69
69
  end
70
70
  it "writes apis correctly" do
71
71
  expect(response["apis"].count).to eq 1
@@ -92,7 +92,7 @@ describe Swagger::Docs::Generator do
92
92
  expect(response["swaggerVersion"]).to eq "1.2"
93
93
  end
94
94
  it "writes basePath correctly" do
95
- expect(response["basePath"]).to eq "/api/v1"
95
+ expect(response["basePath"]).to eq "http://api.no.where/api/v1"
96
96
  end
97
97
  it "writes resourcePath correctly" do
98
98
  expect(response["resourcePath"]).to eq "/sample"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swagger-docs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rich Hollis
metadata.gz.sig CHANGED
Binary file