Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the spec under spec/issues for the issue id 730 #735

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions spec/issues/730_swagger_is_not_detecting_mounted_rack_app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# frozen_string_literal: true

require 'spec_helper'

require 'grape-swagger/entity'

module API
module V1
class Welcome < Grape::API
desc 'Greets user' do
detail 'This is the root api and it will greet user on accessing'
end
get '/' do
{
data: [
{ message: 'Welcome to notes app' }
]
}
end
end
end
end

module API
module V1
class Base < Grape::API
version :v1, using: :path

mount Welcome
end
end
end

module API
class Base < Grape::API
format :json
prefix :api

mount V1::Base

add_swagger_documentation hide_documentation_path: true,
version: 'V1',
info: {
title: 'User notes app',
description: 'Demo app for user notes'
}
end
end

describe 'swagger is not detecting mounted rack app' do
let(:app) { API::Base }

context 'when a rack app is mounted under API::Base' do
context 'when api/v1/ is called' do
subject do
get '/api/v1'
JSON.parse(last_response.body)
end

it 'checks if the response is correct' do
expect(subject).to eq('data' => [{ 'message' => 'Welcome to notes app' }])
end
end

context 'when api/swagger_doc is called' do
subject do
get '/api/swagger_doc'
JSON.parse(last_response.body)
end

it 'checks if the swagger documentation is properly generated' do
expect(subject['paths']).to_not be_nil
end
end
end
end