Setup
# Gemfile
gem 'rspec-swag'
# config.ru
map '/orders' do
run Web::OrdersApp
end
map '/admin/orders' do
run Web::AdminOrdersApp
end
# rspec
describe OrdersApp, :vcr, type: :request do
let(:described_class) { OrdersApp }
path '/index' do
get '' do
....
end
end
end
Problem
rspec-swag generates docs for /index, map is ignored.
So, it isn't possible to test API via Swagger web UI.
I need /orders/index in docs.
How to change code in order to make Swagger docs usable?
Setup
# Gemfile
gem 'rspec-swag'
# config.ru
map '/orders' do
run Web::OrdersApp
end
map '/admin/orders' do
run Web::AdminOrdersApp
end
# rspec
describe OrdersApp, :vcr, type: :request do
let(:described_class) { OrdersApp }
path '/index' do
get '' do
....
end
end
end
Problem
rspec-swag generates docs for /index, map is ignored.
So, it isn't possible to test API via Swagger web UI.
I need /orders/index in docs.
How to change code in order to make Swagger docs usable?
Share Improve this question edited Mar 13 at 9:48 gayavat asked Mar 13 at 9:29 gayavatgayavat 19.4k11 gold badges48 silver badges59 bronze badges 4 |1 Answer
Reset to default 1Solution: use method.
It found here Architecture for a modular, component-based Sinatra Application
# config.ru
run App
# app.ru
class App < Sinatra::Base
use OrdersApp
use AdminOrdersApp
end
class OrdersApp < Sinatra::Base
get '/orders'
end
class AdminOrdersApp < Admin::Base
get '/admin/orders'
end
path '/orders'
?path
is a just a helper the same as usingdescribe '/index'
there is no magic here so if you want/orders/index
you need to tell it that e.g.path '/orders/index'
– engineersmnky Commented Mar 13 at 13:11context '/orders'
. E.gcontext '/orders' do; path '/index' do
...? – engineersmnky Commented Mar 14 at 0:41