apispec 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,260 @@
1
+ * {
2
+ margin: 0px;
3
+ padding: 0px;
4
+ font-size: 11pt;
5
+ }
6
+
7
+ ul {
8
+ margin-left: 20px;
9
+ }
10
+
11
+ body {
12
+ font-family: "Helvetica";
13
+ }
14
+
15
+ h1 {
16
+ color: white;
17
+ padding: 5px;
18
+ font-size: 14pt;
19
+
20
+ border-bottom: 1px solid black;
21
+ background: #3714B0;
22
+ background-image: -webkit-gradient(
23
+ linear,
24
+ left bottom,
25
+ left top,
26
+ color-stop(0, rgb(54,20,176)),
27
+ color-stop(1, rgb(135,103,215))
28
+ );
29
+ background-image: -moz-linear-gradient(
30
+ center bottom,
31
+ rgb(54,20,176) 0%,
32
+ rgb(135,103,215) 100%
33
+ );
34
+ }
35
+
36
+ h2 {
37
+ font-size: 12pt;
38
+ }
39
+
40
+ h3 {
41
+ font-size: 11pt;
42
+ }
43
+
44
+ h4 {
45
+ font-size: 11pt;
46
+ }
47
+
48
+ h5 {
49
+ font-size: 11pt;
50
+ font-weight: normal;
51
+ text-decoration: underline;
52
+ }
53
+
54
+ .example {
55
+ overflow: auto;
56
+ }
57
+
58
+ .codeRay {
59
+ font-family: monospace;
60
+ font-size: 9pt;
61
+ }
62
+
63
+ .response .example, .response .headers, .request .example, .request .headers
64
+ .response .content, .request .content {
65
+ padding: 3px;
66
+ }
67
+
68
+ .object h2 {
69
+ display: block;
70
+ }
71
+
72
+ .resources {}
73
+
74
+ .resource {
75
+ margin: 10px;
76
+ }
77
+
78
+ .resources {
79
+ }
80
+
81
+ .resources .resource h2 {
82
+ padding: 3px;
83
+ border-radius: 4px;
84
+ -moz-border-radius: 4px;
85
+ -webkit-border-radius: 4px;
86
+ border: 1px solid #ccc;
87
+ background: #efefef;
88
+ }
89
+
90
+ .resources .resource h2 .method {
91
+ border-radius: 4px;
92
+ -moz-border-radius: 4px;
93
+ -webkit-border-radius: 4px;
94
+ padding-left: 2px;
95
+ padding-right: 2px;
96
+ background: white;
97
+ color: #866FD7;
98
+ }
99
+
100
+ .resources .resource h2 .path {
101
+ }
102
+
103
+ .resources .resource h2 .path .parameter {
104
+ border-radius: 4px;
105
+ -moz-border-radius: 4px;
106
+ -webkit-border-radius: 4px;
107
+ padding-left: 2px;
108
+ padding-right: 2px;
109
+ background: white;
110
+ margin-left: 3px;
111
+ margin-right: 3px;
112
+ color: #866FD7;
113
+ }
114
+
115
+ .resources .resource p {
116
+ padding: 3px;
117
+ }
118
+
119
+ .resources .resource .request h3, .resources .resource .response h3 {
120
+ border-top: 1px solid #ccc;
121
+ border-bottom: 1px solid #ccc;
122
+ padding: 3px;
123
+ color: white;
124
+ border-radius: 4px 4px 0px 0px;
125
+ -moz-border-radius: 4px 4px 0px 0px;
126
+ -webkit-border-radius: 4px 4px 0px 0px;
127
+ background: #ccc;
128
+ }
129
+
130
+ .resources .resource .response h3 .ok {
131
+ border-radius: 4px;
132
+ -moz-border-radius: 4px;
133
+ -webkit-border-radius: 4px;
134
+ padding-left: 2px;
135
+ padding-right: 2px;
136
+ background: white;
137
+ color: #0ACF00;
138
+ }
139
+
140
+ .resources .resource .response h3 .warn {
141
+ border-radius: 4px;
142
+ -moz-border-radius: 4px;
143
+ -webkit-border-radius: 4px;
144
+ padding-left: 2px;
145
+ padding-right: 2px;
146
+ background: white;
147
+ color: #FD0006;
148
+ }
149
+
150
+ .resources .resource .response h3 .error {
151
+ border-radius: 4px;
152
+ -moz-border-radius: 4px;
153
+ -webkit-border-radius: 4px;
154
+ padding-left: 2px;
155
+ padding-right: 2px;
156
+ background: white;
157
+ color: #FD0006;
158
+ }
159
+
160
+ .field, .object .description, .object .example {
161
+ border-radius: 4px;
162
+ -moz-border-radius: 4px;
163
+ -webkit-border-radius: 4px;
164
+ margin: 3px;
165
+ padding: 3px;
166
+ background: #efefef;
167
+ }
168
+
169
+ .field .name {
170
+ padding: 3px;
171
+
172
+ border-radius: 4px;
173
+ -moz-border-radius: 4px;
174
+ -webkit-border-radius: 4px;
175
+
176
+ background: #2D9B27;
177
+ background-image: -webkit-gradient(
178
+ linear,
179
+ left bottom,
180
+ left top,
181
+ color-stop(0, #078600),
182
+ color-stop(1, #2D9B27)
183
+ );
184
+ background-image: -moz-linear-gradient(
185
+ center bottom,
186
+ #078600 0%,
187
+ #2D9B27 100%
188
+ );
189
+ }
190
+
191
+ .message {
192
+ border-radius: 4px;
193
+ -moz-border-radius: 4px;
194
+ -webkit-border-radius: 4px;
195
+ background: #efefef;
196
+ margin-bottom: 10px;
197
+ margin-left: 10px;
198
+ border-left: 1px solid #ccc;
199
+ border-bottom: 1px solid #ccc;
200
+ border-right: 1px solid #ccc;
201
+ }
202
+
203
+ .message > div {
204
+ margin: 3px;
205
+ }
206
+
207
+ .field .name .default {
208
+ float: right;
209
+ }
210
+
211
+ .field .name .default span {
212
+ font-weight: bolder;
213
+ }
214
+
215
+ .field .name .type {
216
+ font-weight: bolder;
217
+ }
218
+
219
+ .field .name .name {
220
+ font-family: monospace;
221
+ }
222
+
223
+ .field .name a,
224
+ .field .name a:hover,
225
+ .field .name a:active,
226
+ .field .name a:visited {
227
+ color: white;
228
+ text-decoration: none;
229
+ }
230
+
231
+ .field .name .optional {
232
+ border-radius: 4px;
233
+ -moz-border-radius: 4px;
234
+ -webkit-border-radius: 4px;
235
+ padding-left: 2px;
236
+ padding-right: 2px;
237
+ background: white;
238
+ color: #0ACF00;
239
+ float: right;
240
+ }
241
+
242
+ .field .example {
243
+ margin-top: 3px;
244
+ padding: 3px;
245
+ border-radius: 4px;
246
+ -moz-border-radius: 4px;
247
+ -webkit-border-radius: 4px;
248
+ border: 1px solid #ccc;
249
+ }
250
+
251
+ .field .example span {
252
+ border-radius: 4px;
253
+ -moz-border-radius: 4px;
254
+ -webkit-border-radius: 4px;
255
+ padding-left: 2px;
256
+ padding-right: 2px;
257
+ background: white;
258
+ color: #0ACF00;
259
+ float: right;
260
+ }
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe APISpec::Example do
4
+
5
+ end
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe APISpec::Field do
4
+ pending "no spec at the moment"
5
+ end
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe APISpec::Interface do
4
+ pending "no spec at the moment"
5
+ end
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe APISpec::Message do
4
+ pending "no spec at the moment"
5
+ end
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe APISpec::Object do
4
+ pending "no spec at the moment"
5
+ end
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe APISpec::Resource do
4
+ pending "no spec at the moment"
5
+ end
@@ -0,0 +1,28 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
2
+
3
+ EXAMPLE_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", "example"))
4
+
5
+ describe APISpec::Generator do
6
+ before(:each) do
7
+ @generator = APISpec::Generator.new
8
+ @generator.working_directory = EXAMPLE_DIR
9
+ end
10
+
11
+ it "should be possible to parse the example" do
12
+ @generator.parse_files!
13
+ end
14
+
15
+ it "should be possible to parse the example" do
16
+ @generator.parse_files!
17
+ puts @generator.namespace.print_tree()
18
+ end
19
+
20
+ it "should be possible to find fields using there path" do
21
+ @generator.parse_files!
22
+ field = @generator.namespace.find_field("Header.X-User")
23
+
24
+ field = @generator.namespace.find_field("Header.Quota.X-QuotaSize")
25
+ # ...
26
+ field = @generator.namespace.find_field("Mail.attachments")
27
+ end
28
+ end
@@ -0,0 +1 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "apispec"))
@@ -0,0 +1,24 @@
1
+ <div class="field">
2
+ <div class="name">
3
+ <% if @optional %><div class="optional">optional</div><% end %>
4
+ <% if @default %>
5
+ <div class="default">Default: <span><%= @default %></span></div>
6
+ <% end %>
7
+ <% if @type.respond_to? :to_path %>
8
+ <span class="type">
9
+ (<a href="<%= @type.to_path %>" target="content"><%= @type.full_name %></a>)
10
+ </span> <span class="name"><%= @name %></span>
11
+ <% else %>
12
+ <span class="type">(<%= @type %>)</span> <span class="name"><%= @name %></span>
13
+ <% end %>
14
+ </div>
15
+ <% if @example %>
16
+ <div class="example">
17
+ <span>example</span>
18
+ <code><%= @example %></code>
19
+ </div>
20
+ <% end %>
21
+ <div class="description">
22
+ <%= RedCloth.new(@desc || "").to_html %>
23
+ </div>
24
+ </div>
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
2
+ "http://www.w3.org/TR/html4/frameset.dtd">
3
+ <html>
4
+ <head>
5
+ <title>Interface definition</title>
6
+ </head>
7
+ <frameset cols="25%,75%">
8
+ <frame src="links.html" name="navigation">
9
+ <frame src="<%= @namespace.interfaces.first.to_path %>" name="content">
10
+ </frameset>
11
+ </html>
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
5
+ <title><%= @name %> - Interface</title>
6
+ <link href="style.css" type="text/css" media="screen, print" rel="stylesheet" />
7
+ <script type="text/javascript" src="jquery.min.js"></script>
8
+ </head>
9
+ <body>
10
+ <h1>Interface: <%= full_name %></h1>
11
+ <div class="resources">
12
+ <% for resource in @resources do %>
13
+ <div class="resource">
14
+ <%= resource.to_html(generator, self) %>
15
+ </div>
16
+ <% end %>
17
+ </div>
18
+ </body>
19
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
5
+ <title>Overview</title>
6
+ <link href="links.css" type="text/css" media="screen, print" rel="stylesheet" />
7
+ </head>
8
+ <body>
9
+ <h2>Objects</h2>
10
+ <ul class="objects">
11
+ <% for object in @namespace.objects do %>
12
+ <li class="object">
13
+ <a href="<%= object.to_path %>" target="content"><%= object.full_name %></a>
14
+ </li>
15
+ <% end %>
16
+ </ul>
17
+ <h2>Interfaces</h2>
18
+ <ul class="interfaces">
19
+ <% for interface in @namespace.interfaces do %>
20
+ <li class="interface">
21
+ <a href="<%= interface.to_path %>" target="content"><%= interface.full_name %></a>
22
+ </li>
23
+ <% end %>
24
+ </ul>
25
+ </body>
26
+ </html>
@@ -0,0 +1,38 @@
1
+ <p><%= RedCloth.new(@desc || "").to_html %></p>
2
+ <% if @parameters.any? %>
3
+ <div class="parameters">
4
+ <h4>Resource Parameter</h4>
5
+ <% for parameter in @parameters do %>
6
+ <%= parameter.to_html(@generator) %>
7
+ <% end %>
8
+ </div>
9
+ <% end %>
10
+ <% if @headers.any? %>
11
+ <div class="headers">
12
+ <h4>HTTP Header</h4>
13
+ <% for header in @headers do %>
14
+ <%= header.to_html(@generator) %>
15
+ <% end %>
16
+ </div>
17
+ <% end %>
18
+ <% if (@object || @array) || @content_desc %>
19
+ <div class="content">
20
+ <% if @content_desc %>
21
+ <h4>Description</h4>
22
+ <%= RedCloth.new(@content_desc || "").to_html %>
23
+ <% end %>
24
+ <% if @object %>
25
+ <h4>Object</h4>
26
+ <a href="<%= @object.to_path %>"><%= @object.full_name %></a>
27
+ <% elsif @array %>
28
+ <h4>Array</h4>
29
+ Array of <a href="<%= @array.to_path %>"><%= @array.full_name %></a> Objects
30
+ <% end %>
31
+ </div>
32
+ <% end %>
33
+ <% if @example %>
34
+ <div class="example">
35
+ <h4>Example</h4>
36
+ <%= @example.to_html(self) %>
37
+ </div>
38
+ <% end %>
@@ -0,0 +1,27 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
5
+ <title><%= @name %> - Object</title>
6
+ <link href="style.css" type="text/css" rel="stylesheet" />
7
+ </head>
8
+ <body>
9
+ <h1>Object: <%= full_name %></h1>
10
+ <div class="object">
11
+ <% if @desc %>
12
+ <div class="description"><%= RedCloth.new(@desc || "").to_html %></div>
13
+ <% end %>
14
+ <div class="fields">
15
+ <% for field in @fields do %>
16
+ <%= field.to_html(@generator) %>
17
+ <% end %>
18
+ </div>
19
+ <% if @example %>
20
+ <h2>Example</h2>
21
+ <div class="example">
22
+ <%= @example.to_html(self) %>
23
+ </div>
24
+ <% end %>
25
+ </div>
26
+ </body>
27
+ </html>
@@ -0,0 +1,26 @@
1
+ <h2 onclick="$('#<%= uid %>').toggle(2)" style="cursor: pointer;">
2
+ <span class="method"><%= @method.to_s.upcase %></span>
3
+ <span class="path"><%= highlighted_path %></span>
4
+ </h2>
5
+ <div id="<%= uid %>" style="display: none">
6
+ <p>
7
+ <%= RedCloth.new(@desc || "").to_html %>
8
+ </p>
9
+ <% if @request %>
10
+ <div class="request message">
11
+ <h3>Request</h3>
12
+ <%= @request.to_html(@generator, self) %>
13
+ </div>
14
+ <% end %>
15
+ <% for http_code in @response.keys.sort do %>
16
+ <% response = @response[http_code] %>
17
+ <div class="response message">
18
+ <h3>
19
+ <span class="code <%= (http_code >= 400) ? :error : ((http_code >= 300) ? :warn : :ok) %>">
20
+ <%= http_code %></span>
21
+ <span>Response (<%= APISpec::HTTP_STATUS_CODES[http_code] %>)</span>
22
+ </h3>
23
+ <%= response.to_html(@generator, self) %>
24
+ </div>
25
+ <% end %>
26
+ </div>
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: apispec
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 3
10
+ version: 0.0.3
11
+ platform: ruby
12
+ authors:
13
+ - Vincent Landgraf
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-28 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: RedCloth
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 57
30
+ segments:
31
+ - 4
32
+ - 2
33
+ - 7
34
+ version: 4.2.7
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: coderay
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 53
46
+ segments:
47
+ - 0
48
+ - 9
49
+ - 7
50
+ version: 0.9.7
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: rspec
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ hash: 1
62
+ segments:
63
+ - 2
64
+ - 1
65
+ version: "2.1"
66
+ type: :development
67
+ version_requirements: *id003
68
+ description: A documentation generator for http/rest
69
+ email: vilandgr+github@googlemail.com
70
+ executables:
71
+ - apispec
72
+ extensions: []
73
+
74
+ extra_rdoc_files: []
75
+
76
+ files:
77
+ - apispec-0.0.2.gem
78
+ - apispec-0.0.3.gem
79
+ - apispec.gemspec
80
+ - bin/apispec
81
+ - example/datagram/user.json
82
+ - example/example.rb
83
+ - example/user.rb
84
+ - lib/apispec/example.rb
85
+ - lib/apispec/field.rb
86
+ - lib/apispec/generator.rb
87
+ - lib/apispec/http.rb
88
+ - lib/apispec/interface.rb
89
+ - lib/apispec/message.rb
90
+ - lib/apispec/namespace.rb
91
+ - lib/apispec/node.rb
92
+ - lib/apispec/object.rb
93
+ - lib/apispec/resource.rb
94
+ - lib/apispec/version.rb
95
+ - lib/apispec.rb
96
+ - LICENSE
97
+ - Rakefile
98
+ - README.md
99
+ - resources/jquery.min.js
100
+ - resources/links.css
101
+ - resources/stripe.png
102
+ - resources/style.css
103
+ - spec/dsl/example_spec.rb
104
+ - spec/dsl/field_spec.rb
105
+ - spec/dsl/interface_spec.rb
106
+ - spec/dsl/message_spec.rb
107
+ - spec/dsl/object_spec.rb
108
+ - spec/dsl/resource_spec.rb
109
+ - spec/generator_spec.rb
110
+ - spec/spec_helper.rb
111
+ - templates/field.html.erb
112
+ - templates/index.html.erb
113
+ - templates/interface.html.erb
114
+ - templates/links.html.erb
115
+ - templates/message.html.erb
116
+ - templates/object.html.erb
117
+ - templates/resource.html.erb
118
+ has_rdoc: true
119
+ homepage: http://github.com/threez/apispec/
120
+ licenses: []
121
+
122
+ post_install_message:
123
+ rdoc_options: []
124
+
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ hash: 3
133
+ segments:
134
+ - 0
135
+ version: "0"
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ hash: 3
142
+ segments:
143
+ - 0
144
+ version: "0"
145
+ requirements: []
146
+
147
+ rubyforge_project:
148
+ rubygems_version: 1.6.2
149
+ signing_key:
150
+ specification_version: 3
151
+ summary: A ruby based http/rest documentation generator
152
+ test_files:
153
+ - spec/dsl/example_spec.rb
154
+ - spec/dsl/field_spec.rb
155
+ - spec/dsl/interface_spec.rb
156
+ - spec/dsl/message_spec.rb
157
+ - spec/dsl/object_spec.rb
158
+ - spec/dsl/resource_spec.rb
159
+ - spec/generator_spec.rb
160
+ - spec/spec_helper.rb