grape-swagger 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.1
1
+ 0.7.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "grape-swagger"
8
- s.version = "0.7.1"
8
+ s.version = "0.7.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tim Vandecasteele"]
12
- s.date = "2014-02-04"
12
+ s.date = "2014-02-06"
13
13
  s.description = "A simple way to add proper auto generated documentation - that can be displayed with swagger - to your inline described grape API"
14
14
  s.email = "tim.vandecasteele@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -38,7 +38,9 @@ Gem::Specification.new do |s|
38
38
  "spec/hide_api_spec.rb",
39
39
  "spec/non_default_api_spec.rb",
40
40
  "spec/simple_mounted_api_spec.rb",
41
- "spec/spec_helper.rb"
41
+ "spec/spec_helper.rb",
42
+ "test/config.ru",
43
+ "test/nested_api.rb"
42
44
  ]
43
45
  s.homepage = "http://github.com/tim-vandecasteele/grape-swagger"
44
46
  s.licenses = ["MIT"]
@@ -93,11 +93,10 @@ module Grape
93
93
  routes_array = routes.keys.map do |local_route|
94
94
  next if routes[local_route].all?(&:route_hidden)
95
95
 
96
- parsed_path = route.route_version ? "/#{route.route_version}" : ""
97
- parsed_path += "/#{local_route}"
98
- parsed_path += '.{format}' unless @@hide_format
96
+ url_base = parse_path(route.route_path.gsub('(.:format)', ''), route.route_version) if include_base_url
97
+ url_format = '.{format}' unless @@hide_format
99
98
  {
100
- :path => parsed_path,
99
+ :path => "#{url_base}/#{local_route}#{url_format}",
101
100
  #:description => "..."
102
101
  }
103
102
  end.compact
@@ -50,9 +50,9 @@ describe "API Models" do
50
50
  "produces" => ["application/json"],
51
51
  "operations" => [],
52
52
  "apis" => [
53
- { "path" => "/something.{format}" },
54
- { "path" => "/thing.{format}" },
55
- { "path" => "/swagger_doc.{format}" }
53
+ { "path" => "/swagger_doc/something.{format}" },
54
+ { "path" => "/swagger_doc/thing.{format}" },
55
+ { "path" => "/swagger_doc/swagger_doc.{format}" }
56
56
  ]
57
57
  }
58
58
  end
@@ -26,8 +26,8 @@ describe "Default API" do
26
26
  "produces" => ["application/json"],
27
27
  "operations" => [],
28
28
  "apis" => [
29
- { "path" => "/something.{format}" },
30
- { "path" => "/swagger_doc.{format}" }
29
+ { "path" => "/swagger_doc/something.{format}" },
30
+ { "path" => "/swagger_doc/swagger_doc.{format}" }
31
31
  ]
32
32
  }
33
33
  end
@@ -34,8 +34,8 @@ describe "a hide mounted api" do
34
34
  "produces" => ["application/xml", "application/json", "text/plain"],
35
35
  "operations" => [],
36
36
  "apis" => [
37
- { "path" => "/simple.{format}" },
38
- { "path" => "/swagger_doc.{format}" }
37
+ { "path" => "/swagger_doc/simple.{format}" },
38
+ { "path" => "/swagger_doc/swagger_doc.{format}" }
39
39
  ]
40
40
  }
41
41
  end
@@ -76,8 +76,8 @@ describe "a hide mounted api with same namespace" do
76
76
  "produces" => ["application/xml", "application/json", "text/plain"],
77
77
  "operations" => [],
78
78
  "apis" => [
79
- { "path" => "/simple.{format}" },
80
- { "path" => "/swagger_doc.{format}" }
79
+ { "path" => "/swagger_doc/simple.{format}" },
80
+ { "path" => "/swagger_doc/swagger_doc.{format}" }
81
81
  ]
82
82
  }
83
83
  end
@@ -153,8 +153,8 @@ describe "options: " do
153
153
  "produces" => ["application/xml", "application/json", "text/plain"],
154
154
  "operations" => [],
155
155
  "apis" => [
156
- { "path" => "/v1/something.{format}" },
157
- { "path" => "/v1/swagger_doc.{format}" }
156
+ { "path" => "/v1/swagger_doc/something.{format}" },
157
+ { "path" => "/v1/swagger_doc/swagger_doc.{format}" }
158
158
  ]
159
159
  }
160
160
  end
@@ -211,7 +211,7 @@ describe "options: " do
211
211
  "produces" => ["application/xml", "application/json", "text/plain"],
212
212
  "operations" => [],
213
213
  "apis" => [
214
- { "path" => "/something.{format}" }
214
+ { "path" => "/swagger_doc/something.{format}" }
215
215
  ]
216
216
  }
217
217
  end
@@ -326,6 +326,13 @@ describe "options: " do
326
326
  def app; SimpleApiWithDifferentMount end
327
327
 
328
328
 
329
+ it "retrieves the given base-path on /api_doc" do
330
+ get '/api_doc.json'
331
+ JSON.parse(last_response.body)["apis"].each do |api|
332
+ api["path"].should start_with SimpleApiWithDifferentMount::MOUNT_PATH
333
+ end
334
+ end
335
+
329
336
  it "retrieves the same given base-path for mounted-api" do
330
337
  get '/api_doc/something.json'
331
338
  JSON.parse(last_response.body)["apis"].each do |api|
@@ -500,12 +507,12 @@ describe "options: " do
500
507
  "produces" => ["application/xml", "application/json", "text/plain"],
501
508
  "operations" => [],
502
509
  "apis" => [
503
- { "path" => "/first.{format}" }
510
+ { "path" => "/first/swagger_doc/first.{format}" }
504
511
  ]
505
512
  }
506
513
  end
507
514
 
508
- it "retrieves the first swagger-documentation on /second/swagger_doc" do
515
+ it "retrieves the second swagger-documentation on /second/swagger_doc" do
509
516
  get '/second/swagger_doc.json'
510
517
  JSON.parse(last_response.body).should == {
511
518
  "apiVersion" => "0.1",
@@ -515,7 +522,7 @@ describe "options: " do
515
522
  "produces" => ["application/xml", "application/json", "text/plain"],
516
523
  "operations" => [],
517
524
  "apis" => [
518
- { "path" => "/second.{format}" }
525
+ { "path" => "/second/swagger_doc/second.{format}" }
519
526
  ]
520
527
  }
521
528
  end
@@ -76,12 +76,12 @@ describe "a simple mounted api" do
76
76
  "produces" => ["application/xml", "application/json", "text/plain"],
77
77
  "operations" => [],
78
78
  "apis" => [
79
- { "path" => "/simple.{format}" },
80
- { "path" => "/simple-test.{format}" },
81
- { "path" => "/simple_with_headers.{format}" },
82
- { "path" => "/items.{format}" },
83
- { "path" => "/custom.{format}" },
84
- { "path" => "/swagger_doc.{format}" }
79
+ { "path" => "/swagger_doc/simple.{format}" },
80
+ { "path" => "/swagger_doc/simple-test.{format}" },
81
+ { "path" => "/swagger_doc/simple_with_headers.{format}" },
82
+ { "path" => "/swagger_doc/items.{format}" },
83
+ { "path" => "/swagger_doc/custom.{format}" },
84
+ { "path" => "/swagger_doc/swagger_doc.{format}" }
85
85
  ]
86
86
  }
87
87
  end
@@ -0,0 +1,2 @@
1
+ require './nested_api'
2
+ run SimpleApi.new
@@ -0,0 +1,30 @@
1
+ require 'grape'
2
+ require '../lib/grape-swagger'
3
+
4
+ class SimpleNestedApi < Grape::API
5
+ desc "Nested root"
6
+ get 'index' do
7
+ end
8
+ end
9
+
10
+ class SimpleMountedApi < Grape::API
11
+ mount SimpleNestedApi => '/nested'
12
+ desc "Document root"
13
+ get 'index' do
14
+ end
15
+
16
+ add_swagger_documentation mount_path: '/simple/swagger_doc'
17
+ end
18
+
19
+ class OtherSimpleMountedApi < Grape::API
20
+ desc "other simple mounted api root"
21
+ get 'index' do
22
+ end
23
+
24
+ add_swagger_documentation mount_path: '/other_simple/swagger_doc'
25
+ end
26
+
27
+ class SimpleApi < Grape::API
28
+ mount SimpleMountedApi => '/api'
29
+ mount OtherSimpleMountedApi => '/other_api'
30
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-swagger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-04 00:00:00.000000000 Z
12
+ date: 2014-02-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: grape
@@ -202,6 +202,8 @@ files:
202
202
  - spec/non_default_api_spec.rb
203
203
  - spec/simple_mounted_api_spec.rb
204
204
  - spec/spec_helper.rb
205
+ - test/config.ru
206
+ - test/nested_api.rb
205
207
  homepage: http://github.com/tim-vandecasteele/grape-swagger
206
208
  licenses:
207
209
  - MIT
@@ -217,7 +219,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
217
219
  version: '0'
218
220
  segments:
219
221
  - 0
220
- hash: -4023410877516363028
222
+ hash: -17008049882572761
221
223
  required_rubygems_version: !ruby/object:Gem::Requirement
222
224
  none: false
223
225
  requirements: