Skip to content

Commit 0d11175

Browse files
Allow cross origin, so swagger can be used from official site.
1 parent 7035d20 commit 0d11175

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/grape-swagger.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ def parse_path(path)
6060

6161
desc 'Swagger compatible API description'
6262
get '/swagger_doc' do
63+
header['Access-Control-Allow-Origin'] = '*'
64+
header['Access-Control-Request-Method'] = '*'
6365
routes = @@target_class::combined_routes
6466

6567
routes_array = routes.keys.map do |route|
@@ -79,6 +81,8 @@ def parse_path(path)
7981
"name" => { :desc => "Class name of mounted API", :type => "string", :required => true },
8082
}
8183
get '/swagger_doc/:name' do
84+
header['Access-Control-Allow-Origin'] = '*'
85+
header['Access-Control-Request-Method'] = '*'
8286
routes = @@target_class::combined_routes[params[:name]]
8387
routes_array = routes.map do |route|
8488
{

0 commit comments

Comments
 (0)