Skip to content
This repository was archived by the owner on Aug 27, 2021. It is now read-only.

Commit 63fa1e9

Browse files
author
Matt Bernier
committed
Merge pull request #978 from sendgrid/develop
apiblueprint plugin, link fixes 🏢
2 parents c785d2b + d2867c1 commit 63fa1e9

File tree

10 files changed

+551
-36
lines changed

10 files changed

+551
-36
lines changed

plugins/apiv3_example.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ def initialize(tag_name, markup, tokens)
55
@identifier = attributes[0]
66
@request_type = attributes[1]
77
@url = attributes[2]
8-
@data = attributes[3]
8+
@data = markup.gsub(attributes[0],"").gsub(attributes[1],"").gsub(attributes[2],"").strip
9+
910

1011
if attributes[4]
1112
@show_livedoc = attributes[4]
@@ -59,9 +60,13 @@ def render(context)
5960
url = Liquid::Template.parse("{{ url }}").render context
6061
data = Liquid::Template.parse("{{ data }}").render context
6162

62-
data = Hash[URI.decode_www_form(data)]
63-
data = unquote_data(data)
64-
data = data.length > 0 ? JSON.pretty_generate(data) : ""
63+
if data.include? "="
64+
data = Hash[URI.decode_www_form(data)]
65+
data = unquote_data(data)
66+
data = data.length > 0 ? JSON.pretty_generate(data) : ""
67+
else
68+
data = data.length > 0 ? JSON.pretty_generate(JSON.parse(data)) : ""
69+
end
6570

6671
if data.length > 0
6772
data_block = "Request Body<br/>{% codeblock lang:json %}#{data}{% endcodeblock %}"

0 commit comments

Comments
 (0)