From e9c3f2c76b2776ff2c1828f3109e46fc61f83d0a Mon Sep 17 00:00:00 2001 From: dB Date: Mon, 1 Dec 2014 09:34:46 -0500 Subject: [PATCH] Removed unused methods and paths. --- lib/grape-swagger.rb | 17 +---------------- spec/api_models_spec.rb | 4 +++- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/lib/grape-swagger.rb b/lib/grape-swagger.rb index bb6ab3e..85b3711 100644 --- a/lib/grape-swagger.rb +++ b/lib/grape-swagger.rb @@ -298,14 +298,6 @@ module Grape end end - def try(*args, &block) - if args.empty? && block_given? - yield self - elsif respond_to?(args.first) - public_send(*args, &block) - end - end - def strip_heredoc(string) indent = string.scan(/^[ \t]*(?=\S)/).min.try(:size) || 0 string.gsub(/^[ \t]{#{indent}}/, '') @@ -455,14 +447,7 @@ module Grape if route.route_entity type = @@documentation_class.parse_entity_name(route.route_entity) - if route.instance_variable_get(:@options)[:is_array] - operation.merge!( - 'type' => 'array', - 'items' => generate_typeref(type) - ) - else - operation.merge!('type' => type) - end + operation.merge!('type' => type) end operation[:nickname] = route.route_nickname if route.route_nickname diff --git a/spec/api_models_spec.rb b/spec/api_models_spec.rb index 128c51d..53b0baf 100644 --- a/spec/api_models_spec.rb +++ b/spec/api_models_spec.rb @@ -6,6 +6,7 @@ describe 'API Models' do module Entities class Something < Grape::Entity expose :text, documentation: { type: 'string', desc: 'Content of something.' } + expose :links, documentation: { type: 'link', is_array: true } end end @@ -241,7 +242,8 @@ describe 'API Models' do expect(result['models']['Something']).to eq( 'id' => 'Something', 'properties' => { - 'text' => { 'type' => 'string', 'description' => 'Content of something.' } + 'text' => { 'type' => 'string', 'description' => 'Content of something.' }, + 'links' => { 'type' => 'array', 'items' => { '$ref' => 'link' } } } ) end