@@ -24,7 +24,7 @@ class HideApi < Grape::API
2424
2525 def app ; HideApi end
2626
27- it "retrieves swagger-documentation that doesn't include hidden endpoint " do
27+ it "retrieves swagger-documentation that doesn't include hidden endpoints " do
2828 get '/swagger_doc.json'
2929 JSON . parse ( last_response . body ) . should == {
3030 "apiVersion" => "0.1" ,
@@ -38,3 +38,67 @@ def app; HideApi end
3838 }
3939 end
4040end
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