Skip to content

Commit 02d8b28

Browse files
committed
Fixing the case when description has not been initialized until markdown.
1 parent e99f798 commit 02d8b28

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11

22
n.n.n / 2016-03-16
33
==================
4+
[#365](https://github.com/ruby-grape/grape-swagger/pull/365)
5+
6+
- fixes passing markdown with redcarpet even with nil description and detail
7+
48
[#358](https://github.com/ruby-grape/grape-swagger/pull/358)
59

610
- removes `allowMultiple` property from params

lib/grape-swagger/endpoint.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def method_object(route, options, path)
118118
def description_object(route, markdown)
119119
description = route.route_desc if route.route_desc.present?
120120
description = route.route_detail if route.route_detail.present?
121-
description = markdown.markdown(description).chomp if markdown
121+
description = markdown.markdown(description.to_s).chomp if markdown
122122
description
123123
end
124124

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
require 'spec_helper'
2+
3+
describe 'details' do
4+
describe 'details, pass markdown with redcarpet even with nil description and detail', unless: RUBY_PLATFORM.eql?('java') do
5+
include_context "the api entities"
6+
7+
before :all do
8+
module TheApi
9+
class GfmRcDetailApi < Grape::API
10+
format :json
11+
12+
desc nil,
13+
detail: nil,
14+
entity: Entities::UseResponse,
15+
failure: [{code: 400, model: Entities::ApiError}]
16+
get '/use_gfm_rc_detail' do
17+
{ "declared_params" => declared(params) }
18+
end
19+
20+
add_swagger_documentation markdown: GrapeSwagger::Markdown::RedcarpetAdapter.new
21+
end
22+
end
23+
end
24+
25+
def app
26+
TheApi::GfmRcDetailApi
27+
end
28+
29+
subject do
30+
get '/swagger_doc'
31+
JSON.parse(last_response.body)
32+
end
33+
34+
specify do
35+
expect(subject['paths']['/use_gfm_rc_detail']['get']).not_to include('description')
36+
expect(subject['paths']['/use_gfm_rc_detail']['get']['description']).to eql(nil)
37+
end
38+
end
39+
end

0 commit comments

Comments
 (0)