2017-03-08 16:32:31 +08:00
|
|
|
# frozen_string_literal: true
|
2017-03-28 17:15:33 +08:00
|
|
|
|
2015-12-19 03:29:48 +08:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
def details
|
2016-05-07 03:00:36 +08:00
|
|
|
<<-DETAILS
|
2017-03-28 17:15:33 +08:00
|
|
|
# Burgers in Heaven
|
2015-12-19 03:29:48 +08:00
|
|
|
|
2017-03-28 17:15:33 +08:00
|
|
|
> A burger doesn't come for free
|
2015-12-19 03:29:48 +08:00
|
|
|
|
2017-03-28 17:15:33 +08:00
|
|
|
If you want to reserve a burger in heaven, you have to do
|
|
|
|
some crazy stuff on earth.
|
2015-12-19 03:29:48 +08:00
|
|
|
|
2017-03-28 17:15:33 +08:00
|
|
|
```
|
|
|
|
def do_good
|
|
|
|
puts 'help people'
|
|
|
|
end
|
|
|
|
```
|
2015-12-19 03:29:48 +08:00
|
|
|
|
2017-03-28 17:15:33 +08:00
|
|
|
* _Will go to Heaven:_ Probably
|
|
|
|
* _Will go to Hell:_ Probably not
|
|
|
|
DETAILS
|
2015-12-19 03:29:48 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'details' do
|
2024-10-23 20:20:03 +08:00
|
|
|
describe 'take details as it is' do
|
2016-05-07 09:12:26 +08:00
|
|
|
include_context "#{MODEL_PARSER} swagger example"
|
2015-12-19 03:29:48 +08:00
|
|
|
|
|
|
|
before :all do
|
|
|
|
module TheApi
|
|
|
|
class DetailApi < Grape::API
|
|
|
|
format :json
|
|
|
|
|
|
|
|
desc 'This returns something',
|
2016-05-07 03:00:36 +08:00
|
|
|
detail: 'detailed description of the route',
|
|
|
|
entity: Entities::UseResponse,
|
|
|
|
failure: [{ code: 400, model: Entities::ApiError }]
|
2015-12-19 03:29:48 +08:00
|
|
|
get '/use_detail' do
|
2016-05-07 03:00:36 +08:00
|
|
|
{ 'declared_params' => declared(params) }
|
2015-12-19 03:29:48 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
desc 'This returns something' do
|
|
|
|
detail 'detailed description of the route inside the `desc` block'
|
|
|
|
entity Entities::UseResponse
|
2016-05-07 03:00:36 +08:00
|
|
|
failure [{ code: 400, model: Entities::ApiError }]
|
2015-12-19 03:29:48 +08:00
|
|
|
end
|
|
|
|
get '/use_detail_block' do
|
2016-05-07 03:00:36 +08:00
|
|
|
{ 'declared_params' => declared(params) }
|
2015-12-19 03:29:48 +08:00
|
|
|
end
|
|
|
|
|
2018-02-03 21:49:19 +08:00
|
|
|
add_swagger_documentation
|
2015-12-19 03:29:48 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def app
|
|
|
|
TheApi::DetailApi
|
|
|
|
end
|
|
|
|
|
|
|
|
subject do
|
|
|
|
get '/swagger_doc'
|
|
|
|
JSON.parse(last_response.body)
|
|
|
|
end
|
|
|
|
|
|
|
|
specify do
|
2017-01-10 03:04:12 +08:00
|
|
|
expect(subject['paths']['/use_detail']['get']).to include('summary')
|
|
|
|
expect(subject['paths']['/use_detail']['get']['summary']).to eql 'This returns something'
|
2015-12-19 03:29:48 +08:00
|
|
|
expect(subject['paths']['/use_detail']['get']).to include('description')
|
2017-01-10 03:04:12 +08:00
|
|
|
expect(subject['paths']['/use_detail']['get']['description']).to eql 'detailed description of the route'
|
2015-12-19 03:29:48 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
specify do
|
2017-01-10 03:04:12 +08:00
|
|
|
expect(subject['paths']['/use_detail_block']['get']).to include('summary')
|
|
|
|
expect(subject['paths']['/use_detail_block']['get']['summary']).to eql 'This returns something'
|
2015-12-19 03:29:48 +08:00
|
|
|
expect(subject['paths']['/use_detail_block']['get']).to include('description')
|
2017-01-10 03:04:12 +08:00
|
|
|
expect(subject['paths']['/use_detail_block']['get']['description']).to eql 'detailed description of the route inside the `desc` block'
|
2015-12-19 03:29:48 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|