@@ -24,7 +24,7 @@ class HideApi < Grape::API
24
24
25
25
def app ; HideApi end
26
26
27
- it "retrieves swagger-documentation that doesn't include hidden endpoint " do
27
+ it "retrieves swagger-documentation that doesn't include hidden endpoints " do
28
28
get '/swagger_doc.json'
29
29
JSON . parse ( last_response . body ) . should == {
30
30
"apiVersion" => "0.1" ,
@@ -38,3 +38,67 @@ def app; HideApi end
38
38
}
39
39
end
40
40
end
41
+
42
+
43
+ describe "a hide mounted api with same namespace" do
44
+ before :all do
45
+ class HideNamespaceMountedApi < Grape ::API
46
+ desc 'Show this endpoint'
47
+ get '/simple/show' do
48
+ { :foo => 'bar' }
49
+ end
50
+
51
+ desc 'Hide this endpoint' , {
52
+ :hidden => true
53
+ }
54
+ get '/simple/hide' do
55
+ { :foo => 'bar' }
56
+ end
57
+ end
58
+
59
+ class HideNamespaceApi < Grape ::API
60
+ mount HideNamespaceMountedApi
61
+ add_swagger_documentation
62
+ end
63
+ end
64
+
65
+ def app ; HideNamespaceApi end
66
+
67
+ it "retrieves the documentation for mounted-api" do
68
+ get '/swagger_doc.json'
69
+ JSON . parse ( last_response . body ) . should == {
70
+ "apiVersion" => "0.1" ,
71
+ "swaggerVersion" => "1.1" ,
72
+ "basePath" => "http://example.org" ,
73
+ "operations" => [ ] ,
74
+ "apis" => [
75
+ { "path" => "/swagger_doc/simple.{format}" } ,
76
+ { "path" => "/swagger_doc/swagger_doc.{format}" }
77
+ ]
78
+ }
79
+ end
80
+
81
+ it "retrieves the documentation for mounted-api that doesn't include hidden paths" do
82
+ get '/swagger_doc/simple.json'
83
+ JSON . parse ( last_response . body ) . should == {
84
+ "apiVersion" => "0.1" ,
85
+ "swaggerVersion" => "1.1" ,
86
+ "basePath" => "http://example.org" ,
87
+ "resourcePath" => "" ,
88
+ "apis" => [
89
+ {
90
+ "path" => "/simple/show.{format}" ,
91
+ "operations" => [
92
+ {
93
+ "notes" => nil ,
94
+ "summary" => "Show this endpoint" ,
95
+ "nickname" => "GET-simple-show---format-" ,
96
+ "httpMethod" => "GET" ,
97
+ "parameters" => [ ]
98
+ }
99
+ ]
100
+ }
101
+ ]
102
+ }
103
+ end
104
+ end
0 commit comments