swagger-docs 0.2.6 → 0.2.7
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/CHANGELOG.md +4 -0
- data/README.md +2 -2
- data/lib/swagger/docs/generator.rb +1 -1
- data/lib/swagger/docs/version.rb +1 -1
- data/spec/lib/swagger/docs/generator_spec.rb +30 -14
- 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: 6967e0a36e6f1cc25402a43fda60f0bc05a20edc
|
4
|
+
data.tar.gz: 5c29130f3e23ae163f11dd6d6493f18a173da361
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85b1277dab91eded46667469d7bc3fd95dee21001d995f08e0c410081fea39ea84cc35d97f06aeb6bb9dd1bb0ca1fe0f0f07f6d2ac45bcd666a88f29673d1d4c
|
7
|
+
data.tar.gz: 3fffa2a1d4153a28db13ada078ac381cdc7b4408e00df6cfd1303c084c143e084423fa9b9c0cda485a1a22b4f34f300ff3de1e63e54d7a1504413fcf1978aa9b
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -12,7 +12,7 @@ Generates swagger-ui json files for rails apps with APIs. You add the swagger DS
|
|
12
12
|
|
13
13
|
## Swagger Version Specification Support
|
14
14
|
|
15
|
-
This project supports elements of the v1.2 swagger specification. It *does not* support the v2 specification. If you are looking for support for the newer specification the please see the [swagger-blocks](https://github.com/fotinakis/swagger-blocks/) project. I don't currently have any plans to add support for v2.0 at this time.
|
15
|
+
This project supports elements of the v1.2 swagger specification. It *does not* support the v2 specification. If you are looking for support for the newer specification the please see the [swagger-blocks](https://github.com/fotinakis/swagger-blocks/) project. I don't currently have any plans to add support for v2.0 at this time due to time constraints, but I'm open to accepting a PR on this. Contact me if you are interested in helping with that effort - thanks!
|
16
16
|
|
17
17
|
## Example usage
|
18
18
|
|
@@ -138,7 +138,7 @@ The following table shows all the current configuration options and their defaul
|
|
138
138
|
<tr>
|
139
139
|
<td><b>parent_controller</b></td>
|
140
140
|
<td>Assign a different controller to use for the configuration</td>
|
141
|
-
<td
|
141
|
+
<td></td>
|
142
142
|
</tr>
|
143
143
|
|
144
144
|
</tbody>
|
@@ -136,7 +136,7 @@ module Swagger
|
|
136
136
|
klass = Config.log_exception { "#{path.to_s.camelize}Controller".constantize } rescue nil
|
137
137
|
return {action: :skipped, path: path, reason: :klass_not_present} if !klass
|
138
138
|
return {action: :skipped, path: path, reason: :not_swagger_resource} if !klass.methods.include?(:swagger_config) or !klass.swagger_config[:controller]
|
139
|
-
return {action: :skipped, path: path, reason: :not_kind_of_parent_controller} if config[:parent_controller] && !klass < config[:parent_controller]
|
139
|
+
return {action: :skipped, path: path, reason: :not_kind_of_parent_controller} if config[:parent_controller] && !(klass < config[:parent_controller])
|
140
140
|
apis, models, defined_nicknames = [], {}, []
|
141
141
|
routes.select{|i| i.defaults[:controller] == path}.each do |route|
|
142
142
|
unless nickname_defined?(defined_nicknames, path, route) # only add once for each route once e.g. PATCH, PUT
|
data/lib/swagger/docs/version.rb
CHANGED
@@ -5,6 +5,8 @@ describe Swagger::Docs::Generator do
|
|
5
5
|
require "fixtures/controllers/application_controller"
|
6
6
|
require "fixtures/controllers/ignored_controller"
|
7
7
|
|
8
|
+
class FooParentController; end
|
9
|
+
|
8
10
|
before(:each) do
|
9
11
|
FileUtils.rm_rf(tmp_dir)
|
10
12
|
stub_const('ActionController::Base', ApplicationController)
|
@@ -32,6 +34,24 @@ describe Swagger::Docs::Generator do
|
|
32
34
|
let(:file_resource_nested) { tmp_dir + 'nested.json' }
|
33
35
|
let(:file_resource_custom_resource_path) { tmp_dir + 'custom_resource_path.json' }
|
34
36
|
|
37
|
+
let(:default_config) {
|
38
|
+
{
|
39
|
+
:controller_base_path => "api/v1",
|
40
|
+
:api_file_path => "#{tmp_dir}",
|
41
|
+
:base_path => "http://api.no.where/",
|
42
|
+
:attributes => {
|
43
|
+
:info => {
|
44
|
+
"title" => "Swagger Sample App",
|
45
|
+
"description" => "This is a sample description.",
|
46
|
+
"termsOfServiceUrl" => "http://helloreverb.com/terms/",
|
47
|
+
"contact" => "apiteam@wordnik.com",
|
48
|
+
"license" => "Apache 2.0",
|
49
|
+
"licenseUrl" => "http://www.apache.org/licenses/LICENSE-2.0.html"
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
35
55
|
let(:controllers) { [
|
36
56
|
"fixtures/controllers/sample_controller",
|
37
57
|
"fixtures/controllers/nested_controller",
|
@@ -100,20 +120,7 @@ describe Swagger::Docs::Generator do
|
|
100
120
|
end
|
101
121
|
end
|
102
122
|
context "with controller base path" do
|
103
|
-
let(:config) { Swagger::Docs::Config.register_apis({
|
104
|
-
DEFAULT_VER => {:controller_base_path => "api/v1", :api_file_path => "#{tmp_dir}", :base_path => "http://api.no.where/",
|
105
|
-
:attributes => {
|
106
|
-
:info => {
|
107
|
-
"title" => "Swagger Sample App",
|
108
|
-
"description" => "This is a sample description.",
|
109
|
-
"termsOfServiceUrl" => "http://helloreverb.com/terms/",
|
110
|
-
"contact" => "apiteam@wordnik.com",
|
111
|
-
"license" => "Apache 2.0",
|
112
|
-
"licenseUrl" => "http://www.apache.org/licenses/LICENSE-2.0.html"
|
113
|
-
}
|
114
|
-
}
|
115
|
-
}
|
116
|
-
})}
|
123
|
+
let(:config) { Swagger::Docs::Config.register_apis({DEFAULT_VER => default_config})}
|
117
124
|
let(:file_resource) { tmp_dir + 'sample.json' }
|
118
125
|
let(:resource) { file_resource.read }
|
119
126
|
let(:response) { JSON.parse(resource) }
|
@@ -131,6 +138,15 @@ describe Swagger::Docs::Generator do
|
|
131
138
|
expect(file_resource).to_not exist
|
132
139
|
end
|
133
140
|
end
|
141
|
+
describe "#generate" do
|
142
|
+
it "respects parent_controller config option" do
|
143
|
+
new_config = default_config
|
144
|
+
new_config[:parent_controller] = ApplicationController
|
145
|
+
api_config = Swagger::Docs::Config.register_apis(DEFAULT_VER => new_config)
|
146
|
+
results = generate(api_config)
|
147
|
+
expect(results[DEFAULT_VER][:processed].count).to eq(controllers.count)
|
148
|
+
end
|
149
|
+
end
|
134
150
|
describe "#write_docs" do
|
135
151
|
context "no apis registered" do
|
136
152
|
before(:each) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swagger-docs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rich Hollis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|