raml_doc 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d87e088e96bd61223b2b3bc512c59edc4f6cd37
4
- data.tar.gz: e4736c4e6e512501015c9db5d690ebbaa095c97e
3
+ metadata.gz: 80c4be74b32b4ec7b49b3d8b92f919a043183a57
4
+ data.tar.gz: 14a8d865bc9c7ed4f4e1ea3de3240777b89ed5de
5
5
  SHA512:
6
- metadata.gz: eeadeaf1c9d143adb536466da0f560c828c2b3187c915f5cf8a9308fde1f7b08e90419c88edf66dbac44fb5dbcd3b8abcf2f09250e50a3ade858275bbc6ed941
7
- data.tar.gz: d63922eb36496eaea1f324b2d0795b2c0ab91280017dd116cf30a942953a9d5aa3a118446ca310f66fe2abdfb35f111f225f9bf7f8c4fdf45feec3f5338d9685
6
+ metadata.gz: 87e1720f5d227dd335602183ff830ecb459422883194c0f70d6a829877ecc835a8d7db892f47fe4319084cedf5b604e5387f18c145a2424d39a34f3b2bb40d35
7
+ data.tar.gz: 06881dbcd3dbd2dc8a0471a54533997de4a8e21de29ab12578932858a026a6cb4e4a3e429ad983b7e343f47e1d7e4ca86c499dfc854658c0e4827b27d5137650
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- raml_doc (0.0.2)
4
+ raml_doc (0.0.3)
5
5
  kramdown (= 1.11.1)
6
6
  raml_ruby (= 0.1.2)
7
7
 
@@ -22,7 +22,7 @@
22
22
  <div class="panel panel-default">
23
23
  <div class="panel-heading">
24
24
  <h3 class="panel-title">
25
- <span class="label label-info"><%= method.name %></span>
25
+ <span class="label <%= method_boostrap_label_css_class method %>"><%= method.name %></span>
26
26
  <a class="text-muted" href="<%= @raml.base_uri + resource.resource_path %>">
27
27
  <%= @raml.base_uri + resource.resource_path %>
28
28
  </a>
@@ -53,6 +53,13 @@
53
53
  </a>
54
54
  </li>
55
55
  <% end %>
56
+ <% if present? method.bodies %>
57
+ <li role="presentation">
58
+ <a href="#<%= method_element_id method, "request-bodies" %>" aria-controls="home" role="tab" data-toggle="tab">
59
+ Request Bodies
60
+ </a>
61
+ </li>
62
+ <% end %>
56
63
  <% if present? method.responses %>
57
64
  <li role="presentation">
58
65
  <a href="#<%= method_element_id method, "responses" %>" aria-controls="home" role="tab" data-toggle="tab">
@@ -91,8 +98,14 @@
91
98
  <ul>
92
99
  <% method.query_parameters.each do |_, parameter| %>
93
100
  <li>
94
- <var><strong><%= parameter.required ? "*#{parameter.name}" : "[#{parameter.name}]" %></strong></var>
101
+ <var>
102
+ <strong><%= parameter.name %></strong>
103
+ <% if parameter.required %>
104
+ <span class="label label-danger">required</span>
105
+ <% end %>
106
+ </var>
95
107
  <% if parameter.example %>
108
+ <i class="fa fa-long-arrow-right" aria-hidden="true"></i>
96
109
  <code><%= parameter.example %></code>
97
110
  <% end %>
98
111
  <p><small><%= markdown parameter.description %></small></p>
@@ -101,6 +114,35 @@
101
114
  </ul>
102
115
  </p>
103
116
  </div>
117
+ <div role="tabpanel" class="tab-pane" id="<%= method_element_id method, "request-bodies" %>">
118
+ <h3>
119
+ <i class="fa fa-info-circle" aria-hidden="true"></i>
120
+ Request Bodies
121
+ </h3>
122
+ <% method.bodies.each do |_, body| %>
123
+ <h4>Body</h4>
124
+ <h5>Form Parameters</h5>
125
+ <p>
126
+ <ul>
127
+ <% body.form_parameters.each do |_, parameter| %>
128
+ <li>
129
+ <var>
130
+ <strong><%= parameter.name %></strong>
131
+ <% if parameter.required %>
132
+ <span class="label label-danger">required</span>
133
+ <% end %>
134
+ </var>
135
+ <% if parameter.example %>
136
+ <i class="fa fa-long-arrow-right" aria-hidden="true"></i>
137
+ <code><%= parameter.example %></code>
138
+ <% end %>
139
+ <p><small><%= markdown parameter.description %></small></p>
140
+ </li>
141
+ <% end %>
142
+ </ul>
143
+ </p>
144
+ <% end %>
145
+ </div>
104
146
  <div role="tabpanel" class="tab-pane" id="<%= method_element_id method, "responses" %>">
105
147
  <h3>
106
148
  <i class="fa fa-info-circle" aria-hidden="true"></i>
@@ -113,7 +155,17 @@
113
155
  <i class="fa fa-info-circle" aria-hidden="true"></i>
114
156
  Examples
115
157
  </h3>
116
- <p>...</p>
158
+ <% if present? method.bodies %>
159
+ <% method.bodies.each do |_, body| %>
160
+ <p>
161
+ <pre>curl -X <%= method.name.upcase %> --data '<%= method_querystring_example body.form_parameters %>' <%= method_uri_example method %></pre>
162
+ </p>
163
+ <% end %>
164
+ <% else %>
165
+ <p>
166
+ <pre>curl -X <%= method.name.upcase %> <%= method_uri_example method %></pre>
167
+ </p>
168
+ <% end %>
117
169
  </div>
118
170
  </div>
119
171
  </div>
@@ -143,6 +195,7 @@
143
195
  h3 { margin-top: 20px; margin-bottom: 20px; }
144
196
  p, div { font-family: "Merriweather", serif; }
145
197
  code, pre, kbd, var { font-family: monospace; }
198
+ pre { white-space: pre-wrap; word-wrap: break-word; }
146
199
  .panel { margin-left: 30px; }
147
200
  </style>
148
201
  <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
@@ -1,3 +1,3 @@
1
1
  module RamlDoc
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -1,3 +1,4 @@
1
+ require "cgi"
1
2
  require "kramdown"
2
3
  require "raml_doc/raml_helper"
3
4
 
@@ -29,5 +30,34 @@ module RamlDoc
29
30
  args << method.parent.resource_path_name
30
31
  args.compact.join "-"
31
32
  end
33
+
34
+ def method_querystring_example(parameters)
35
+ qs = []
36
+ parameters.each do |_, parameter|
37
+ next if parameter.example.nil?
38
+ next unless parameter.required || parameter.name.start_with?("utm_")
39
+ qs << "#{parameter.name}=#{CGI.escape parameter.example}"
40
+ end
41
+ qs.join("&").strip
42
+ end
43
+
44
+ def method_uri_example(method)
45
+ uri = []
46
+ uri << "#{method.parent.parent.base_uri}#{method.parent.resource_path}"
47
+ uri << "#{method_querystring_example method.query_parameters}"
48
+ uri.keep_if { |entry| present? entry }
49
+ uri.join "?"
50
+ end
51
+
52
+ def method_boostrap_label_css_class(method)
53
+ case method.name
54
+ when "get" then "label-success"
55
+ when "post" then "label-primary"
56
+ when "put" then "label-info"
57
+ when "patch" then "label-warning"
58
+ when "delete" then "label-danger"
59
+ else "label-default"
60
+ end
61
+ end
32
62
  end
33
63
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raml_doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Hopkins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-25 00:00:00.000000000 Z
11
+ date: 2016-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: raml_ruby