blib/lib/Froody/API/XML.pm

filter: Statementstmt 96.6% 203 / 210 Branchbran 77.2% 51 / 66 Conditioncond 79.1% 19 / 24 MC/DCmcdc 61.5% 8 / 13 Subroutinesub 91.6% 22 / 24 Podpod 100% 6 / 6 totaltotal 90.0% 309 / 343 CC 54 SCAR 20.7
CC
54
Cov
91%
_text_only
30.0
_xml_to_structure_hash
12.1
_arguments
9.0
CRAP 7.9
« blib/lib/Froody/Request/Apache.pm ↑ Summary blib/lib/Froody/Server.pm »
1 package Froody::API::XML;
2 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 14 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 14 ▶use Froody::Method;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 14 ▶use Froody::ErrorType;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 14 ▶use Froody::Response::String;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 14 ▶use Froody::Logger;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 14 my $logger = get_logger("froody.api.xml");
10  
11 14 ▶use base qw(Froody::API);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 14 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 =head1 NAME
15  
16 Froody::API::XML - Define a Froody API with xml
17  
18 =head1 SYNOPSIS
19  
20 package MyAPI;
21 use base qw{Froody::API::XML};
22
23 sub xml {
24 return q{
25 <spec>
26 <methods>
27 <method name="foo">....</method>
28 </methods>
29 </spec>
30 };
31 }
32
33 1;
34  
35 =head1 DESCRIPTION
36  
37 This class is a helper base class for Froody::API. It can parse a standard
38 format of XML and turn it into a bunch of Froody::Method objects.
39  
40 =head1 METHODS
41  
42 =over
43  
44 =item xml
45  
46 Subclasses must override this method to provide an XML specification.
47  
48 =cut
49  
50 0 ▶sub xml {
Subroutine xml: not called CC=1 SCAR=6.9
Pod documented
51 0 Froody::Error->throw("perl.use", "Please override the abstract method Froody::API::XML::xml()");
52 }
53  
54 =item load( xml )
55  
56 Calls C<load_spec()> with the return value of the C<xml> method.
57  
58 =cut
59  
60 20 ▶sub load {
Subroutine load: called CC=1 SCAR=0.0
Pod documented
61 20 my $class = shift;
62 20 return $class->load_spec($class->xml);
63 }
64  
65 =item load_spec($xml_string)
66  
67 Turns a method spec xml string into an array of
68 C<Froody::Method> objects.
69  
70 =cut
71  
72 35 ▶sub load_spec {
Subroutine load_spec: called CC=6 SCAR=17.9
Pod documented
73 35 my ($class, $xml) = @_;
74 35 ▶ unless ($xml)
Branch: 1 branch
BranchTrueFalseTotal
unless ($xml) 2 33 35
75 2 { Froody::Error->throw("perl.methodcall.param", "No xml passed to load_spec!") }
76
77 33 my $parser = $class->parser;
78 my $doc = UNIVERSAL::isa($xml, 'XML::LibXML::Node') ? $xml
79 33 ▶ : eval { $parser->parse_string($xml) };
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($xml, 'XML::LibXML::Node') ? : 2 31 33
80 33 ▶ Froody::Error->throw("froody.xml.invalid", "Invalid xml passed: $@")
Branch: 1 branch
BranchTrueFalseTotal
if $@ 2 31 33
81 if $@;
82 31 $doc->indexElements;
83
84 31 my $method_node_path = '/spec/methods/method';
85 31 my $error_node_path = '/spec/errortypes/errortype';
86 31 ▶ if ($doc->documentElement->nodeName eq 'rsp') {
Branch: 1 branch
BranchTrueFalseTotal
if ($doc->documentElement->nodeName eq "rsp") 2 29 31
87 2 $method_node_path = '/rsp'.$method_node_path;
88 2 $error_node_path = '/rsp'.$error_node_path;
89 }
90  
91 31 ▶ my @methods = map { $class->load_method($_) }
Branch: 1 branch
BranchTrueFalseTotal
my(@methods) = map({$class->load_method($_);} $doc->findnodes($method_node_path)) or "Froody::Error"->throw("froody.xml.nomethods", "no methods found in spec!") 27 2 29
92 $doc->findnodes($method_node_path)
93 or Froody::Error->throw('froody.xml.nomethods', "no methods found in spec!");
94
95 27 my @errortypes = map { $class->load_errortype($_) }
96 $doc->findnodes($error_node_path);
97  
98 27 return (@methods, @errortypes);
99 }
100  
101 =item load_method($element)
102  
103 Passed an XML::LibXML::Element that represents a <method>...</method>,
104 this returns an instance of Froody::Method that represents that method.
105  
106 =cut
107  
108 186 ▶sub load_method {
Subroutine load_method: called CC=4 SCAR=13.9
Pod documented
109 186 my ($class, $method_element) = @_;
110 186 ▶ unless (UNIVERSAL::isa($method_element, 'XML::LibXML::Element')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (UNIVERSAL::isa($method_element, "XML::LibXML::Element")) 2 184 186
111 2 Froody::Error->throw("perl.methodcall.param",
112 "we were expected to be passed a XML::LibXML::Element!");
113 }
114
115 # work out the name of the element
116 184 ▶ my $full_name = $method_element->findvalue('./@name')
Branch: 1 branch
BranchTrueFalseTotal
my $full_name = $method_element->findvalue("./\@name") or "Froody::Error"->throw("froody.xml", q[Can't find the attribute 'name' for the method definition within ] . $method_element->toString) 183 1 184
117 or Froody::Error->throw("froody.xml",
118 "Can't find the attribute 'name' for the method definition within "
119 .$method_element->toString);
120  
121  
122 # create a new method
123 183 my $method = Froody::Method->new()
124 ->full_name($full_name)
125 ->arguments($class->_arguments($method_element))
126 ->errors($class->_errors($method_element))
127 ->needslogin($class->_needslogin($method_element));
128 182 my ($response_element) = $class->_extract_response($method_element, $full_name);
129 182 ▶ if ($response_element) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response_element) { } 145 37 182
130 145 my ($structure, $example_data) = $class->_extract_structure($response_element);
131 145 $method->structure($structure);
132 145 my $example = Froody::Response::String->new;
133 145 $example->set_string("<rsp status='ok'>".$response_element->toString(1)."</rsp>");
134 145 $example->structure($method);
135
136 145 $method->example_response($example);
137 145 weaken($example->{structure});
138 } else {
139 37 $method->structure({})
140 }
141  
142 182 my $desc = $method_element->findvalue("./description");
143 182 $desc =~ s/^\s+//;
144 182 $desc =~ s/\s+$//;
145 182 $method->description($desc);
146  
147 182 return $method;
148 }
149  
150 # okay, we're parsing this
151 # <arguments>
152 # <argument name="sex">male or female</argument>
153 # <argument name="hair" optional="1">optionally list hair color</argument>
154 # <argument name="hair" optional="1">optionally list hair color</argument>
155 # </arguments>
156  
157 182 ▶sub _arguments {
Subroutine _arguments: called CC=9 SCAR=22.0
158 182 my ($class, $method_element) = @_;
159  
160 # get all of the argument elements
161 182 my @argument_elements = $method_element->findnodes('./arguments/argument');
162  
163 # convert them into a big old hash
164 182 my %arguments;
165 182 foreach my $argument_element (@argument_elements)
166 {
167 # pull our the attributes
168
169 98 my $name = $argument_element->findvalue('./@name');
170 98 ▶ my $optional = $argument_element->findvalue('./@optional') || 0;
Condition100%2/2
$argument_element->findvalue('./@optional') || 0
l!l
2771
MC/DC100%1/1
$argument_element->findvalue('./@optional') || 0
$argument_element->findvalue('./@optional')
Truth table100%2/2
A
A= $argument_element->findvalue('./@optional')
Aresult
11
00
171 98 ▶ my $type = $argument_element->findvalue('./@type') || 'text';
Condition100%2/2
$argument_element->findvalue('./@type') || 'text'
l!l
4553
MC/DC100%1/1
$argument_element->findvalue('./@type') || 'text'
$argument_element->findvalue('./@type')
Truth table100%2/2
A
A= $argument_element->findvalue('./@type')
Aresult
11
00
172  
173 # Ugh. Track this down.
174 98 ▶ $type = 'text' if $type eq 'scalar';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "scalar" 0 98 98
175 98 my @types = split /,/, $type;
176  
177 # extract the contents of <argument>...</argument> as the description
178 98 my $description = $argument_element->findvalue('./text()');
179  
180 98 ▶ $arguments{$name}{multiple} = 1 unless $type eq 'text';
Branch: 1 branch
BranchTrueFalseTotal
unless $type eq "text" 32 66 98
181 98 $arguments{$name}{optional} = $optional;
182 98 $arguments{$name}{doc} = $description;
183 98 $arguments{$name}{type} = \@types;
184  
185 # XXX: compose the list in Froody::Argument
186 98 require Froody::Argument;
187 98 my @TYPES = keys %{ Froody::Argument->_types() };
188 98 push @TYPES, 'remaining'; # a special case.
189 98 for my $_type (@types) {
190 Froody::Error->throw("froody.api.unsupportedtype", "The type '$_type' is unsupported")
191 108 ▶ unless grep { $_type eq $_ } @TYPES;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_type eq $_;} @TYPES 0 108 108
192 108 ▶ if ($_type eq 'remaining') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_type eq "remaining") 5 103 108
193 5 $arguments{$name}{optional} = 1;
194 }
195 }
196  
197 }
198  
199 182 return \%arguments;
200 }
201  
202 # get the response element from the XML
203 182 ▶sub _extract_response {
Subroutine _extract_response: called CC=2 SCAR=6.9
204 182 my ($class, $dom, $full_name) = @_;
205 182 my ($structure) = $dom->findnodes("./response");
206 182 ▶ return unless $structure; # we don't *have* to have a structure
Branch: 1 branch
BranchTrueFalseTotal
unless $structure 35 147 182
207  
208 147 return $class->_extract_children($structure, $full_name);
209 }
210  
211 147 ▶sub _extract_children {
Subroutine _extract_children: called CC=3 SCAR=11.0
212 147 my ($class, $structure, $full_name) = @_;
213  
214 147 my @child_nodes = grep { $_->isa('XML::LibXML::Element') } $structure->childNodes;
215 147 ▶ unless (@child_nodes) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@child_nodes) 26 121 147
216 26 my $structure_xml = '<rsp>' . $structure->textContent . '</rsp>';
217  
218 26 my $structure_doc = $class->parser->parse_string($structure_xml);
219 26 @child_nodes = grep { $_->isa('XML::LibXML::Element') } $structure_doc->documentElement->childNodes();
220 }
221 147 ▶ Froody::Error->throw("froody.xml", "Too many top level elements in the structure for $full_name")
Branch: 1 branch
BranchTrueFalseTotal
unless @child_nodes <= 1 0 147 147
222 unless @child_nodes <= 1;
223  
224 147 return @child_nodes;
225 }
226  
227 174 ▶sub _extract_structure {
Subroutine _extract_structure: called CC=2 SCAR=7.1
228 174 my ($class, $dom) = @_;
229  
230 174 ▶ return unless $dom;
Branch: 1 branch
BranchTrueFalseTotal
unless $dom 0 174 174
231 174 return _xml_to_structure_hash($dom);
232 }
233  
234 0 ▶sub _text_only {
Subroutine _text_only: not called CC=5 SCAR=34.0
235 0 my $entry = shift;
236 0 ▶ return if exists $entry->{attr};
Branch: 1 branch
BranchTrueFalseTotal
if exists $entry->{"attr"} 0 0 0
237 0 ▶ return if exists $entry->{elts};
Branch: 1 branch
BranchTrueFalseTotal
if exists $entry->{"elts"} 0 0 0
238 0 ▶ return if exists $entry->{multi};
Branch: 1 branch
BranchTrueFalseTotal
if exists $entry->{"multi"} 0 0 0
239 0 ▶ return 1 if $entry->{text};
Branch: 1 branch
BranchTrueFalseTotal
if $entry->{"text"} 0 0 0
240 }
241  
242 174 ▶sub _xml_to_structure_hash {
Subroutine _xml_to_structure_hash: called CC=12 SCAR=24.9
243 174 my $node = shift;
244  
245 # Each element is explained in the top level results hash.
246 174 my $spec = {};
247 174 my $name = $node->nodeName;
248 174 $spec->{''}{elts}{ $name }++;
249
250
251 # Create the specification using a breadth-first iteration
252 174 my @list = ( $node, $name );
253 174 my %visited;
254 174 ▶ for(my $i = 0; $i < @list; $i += 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @list) 819 174 993
255 819 my ($node, $path) = @list[$i..$i+1];
256 # Add all non text child nodes to the end of the list.
257 819 my $name = $node->nodeName;
258 819 my @elements;
259  
260 819 my $has_non_text_nodes = 0;
261 819 ▶ my $child_spec = $spec->{$path}{elts} ||= {};
Condition100%2/2
$spec->{$path}{"elts"} ||= {}
l!l
293526
MC/DC100%1/1
$spec->{$path}{"elts"} ||= {}
$spec->{$path}{"elts"}
Truth table100%2/2
A
A= $spec->{$path}{"elts"}
Aresult
11
00
262  
263 819 ▶ my $prefix = $path ? "$path/" : "";
Branch: 1 branch
BranchTrueFalseTotal
$path ? : 819 0 819
264 819 for my $child ($node->childNodes) {
265 # Check if there's any text in the element we're looking at
266 1167 ▶ if ($child->isa('XML::LibXML::Text')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($child->isa('XML::LibXML::Text')) { } 522 645 1167
267 522 next;
268 } else {
269 645 $has_non_text_nodes = 1;
270 }
271 645 my $nn = $child->nodeName;
272 # Mark each child element seen as being a child element of our spec list
273 645 ▶ $child_spec->{$nn}++ unless $visited{$path};
Branch: 1 branch
BranchTrueFalseTotal
unless $visited{$path} 530 115 645
274 645 push @list, ($child, $prefix.$nn);
275 }
276
277 # We've been here. Move along.
278 819 ▶ if ($visited{$path}++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($visited{$path}++) 293 526 819
279 293 $spec->{$path}{multi}++;
280 293 next;
281 }
282
283 # Gather all attributes
284 526 foreach ($node->attributes) {
285 287 my $aname = $_->nodeName;
286 287 $spec->{$path}{attr}{$aname}++;
287 }
288
289 526 ▶ my $is_nonempty_root = !length($prefix) && $spec->{$path};
Condition33%1/3
!length($prefix) && $spec->{$path}
!ll&&!rl&&r
52600
MC/DC0%0/2
!length($prefix) && $spec->{$path}
!length($prefix) $spec->{$path}
Truth table33%1/3
not(A) && B
A= !length($prefix)B= $spec->{$path}
ABresult
0X0
100
111
290 526 ▶ $spec->{$path}{text} = 1
Branch: 1 branch
BranchTrueFalseTotal
unless $has_non_text_nodes or $is_nonempty_root 303 223 526
Condition66%2/3
$has_non_text_nodes or $is_nonempty_root
l!l&&r!l&&!r
2230303
MC/DC50%1/2
$has_non_text_nodes or $is_nonempty_root
$has_non_text_nodes $is_nonempty_root
Truth table66%2/3
A or B
A= $has_non_text_nodesB= $is_nonempty_root
ABresult
1X1
011
000
291 unless $has_non_text_nodes || $is_nonempty_root;
292 }
293
294 174 _flatten_specification($spec);
295  
296 # TODO: Flatten the text nodes.
297  
298 174 return $spec;
299 # TODO: Handling types is a Service level detail.
300 }
301  
302 174 ▶sub _flatten_specification {
Subroutine _flatten_specification: called CC=9 SCAR=22.0
303 174 my $spec = shift;
304
305 # Flatten element and attribute names, and make
306 # sure that the multiplicity flag is correctly set.
307 174 foreach my $key (keys %$spec) {
308 # Flatten the list of names
309 700 my $prefix = $key;
310 700 ▶ $prefix .= $prefix ? '/' : '';
Branch: 1 branch
BranchTrueFalseTotal
$prefix ? : 526 174 700
311 700 foreach my $name (qw{attr elts}) {
312 1400 my @names = sort keys %{ $spec->{$key}{$name} };
313 1400 ▶ if ($name eq 'elts') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "elts") 700 700 1400
314 700 for my $cpath (@names) {
315 526 ▶ $spec->{$prefix.$cpath}{multi} = ($spec->{$key}{$name}{$cpath} > 1)
Branch: 1 branch
BranchTrueFalseTotal
$spec->{$key}{$name}{$cpath} > 1 ? : 150 376 526
316 ? 1
317 : 0
318 ;
319 }
320 }
321 1400 $spec->{$key}{$name} = \@names;
322 }
323 700 ▶ $spec->{$key}{multi} ||= 0;
Condition100%2/2
$spec->{$key}{"multi"} ||= 0
l!l
178522
MC/DC100%1/1
$spec->{$key}{"multi"} ||= 0
$spec->{$key}{"multi"}
Truth table100%2/2
A
A= $spec->{$key}{"multi"}
Aresult
11
00
324 700 ▶ $spec->{$key}{text} ||= 0;
Condition100%2/2
$spec->{$key}{"text"} ||= 0
l!l
303397
MC/DC100%1/1
$spec->{$key}{"text"} ||= 0
$spec->{$key}{"text"}
Truth table100%2/2
A
A= $spec->{$key}{"text"}
Aresult
11
00
325 }
326 }
327  
328 182 ▶sub _errors {
Subroutine _errors: called CC=4 SCAR=13.9
329 182 my ($class, $method_element) = @_;
330  
331 # extract out the error methods
332 182 my @error_elements = $method_element->findnodes('./errors/error');
333  
334 # build them into a hash
335 182 my %errors;
336 182 foreach my $error_element (@error_elements) {
337
338 # extract the attributes
339 38 ▶ my $code = $error_element->findvalue('./@code') || '';
Condition50%1/2
$error_element->findvalue('./@code') || ''
l!l
380
MC/DC0%0/1
$error_element->findvalue('./@code') || ''
$error_element->findvalue('./@code')
Truth table50%1/2
A
A= $error_element->findvalue('./@code')
Aresult
11
00
340 38 my $message = $error_element->findvalue('./@message');
341  
342 # convert them into a a hash that has the error number as the
343 # key, and contains a hashref with a message and description in it
344 38 my $description = $error_element->textContent;
345 38 $description =~ s/^\s+//;
346 38 $description =~ s/\s+$//;
347 38 ▶ $errors{ $code } = {
Condition100%2/2
$message || ''
l!l
2810
MC/DC100%1/1
$message || ''
$message
Truth table100%2/2
A
A= $message
Aresult
11
00
348 message => $message || '',
349 description => $description
350 };
351 }
352  
353 182 return \%errors;
354 }
355  
356 # returns true if the method element passed needs a login, i.e. has
357 # an attribute <method needslogin="1">. Returns false in all other cases
358 182 ▶sub _needslogin {
Subroutine _needslogin: called CC=2 SCAR=6.9
359 182 my ($class, $method_element) = @_;
360 182 ▶ return $method_element->findvalue('./@needslogin') || 0;
Condition100%2/2
$method_element->findvalue('./@needslogin') || 0
l!l
1181
MC/DC100%1/1
$method_element->findvalue('./@needslogin') || 0
$method_element->findvalue('./@needslogin')
Truth table100%2/2
A
A= $method_element->findvalue('./@needslogin')
Aresult
11
00
361 }
362  
363 =item load_errortype
364  
365 Passed an XML::LibXML::Element that represents an <errortype>...</errortype>,
366 this returns an instance of Froody::ErrorType that represents that error type.
367  
368 =cut
369  
370 31 ▶sub load_errortype {
Subroutine load_errortype: called CC=7 SCAR=19.5
Pod documented
371 31 my ($class, $et_element) = @_;
372
373 31 ▶ unless (UNIVERSAL::isa($et_element, 'XML::LibXML::Element')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (UNIVERSAL::isa($et_element, "XML::LibXML::Element")) 2 29 31
374 2 Froody::Error->throw("perl.methodcall.param",
375 "we were expected to be passed a XML::LibXML::Element!");
376 }
377
378 # work out the name of the element
379 29 ▶ my $code = $et_element->findvalue('./@code') || '';
Condition50%1/2
$et_element->findvalue('./@code') || ''
l!l
290
MC/DC0%0/1
$et_element->findvalue('./@code') || ''
$et_element->findvalue('./@code')
Truth table50%1/2
A
A= $et_element->findvalue('./@code')
Aresult
11
00
380 29 ▶ Carp::cluck "no code in ".$et_element->toString(1) unless defined $code;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $code 0 29 29
381  
382 29 my $et = Froody::ErrorType->new;
383 29 $et->name($code);
384  
385  
386 29 ▶ unless (grep { !UNIVERSAL::isa($_, "XML::LibXML::Text") } $et_element->childNodes) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {not UNIVERSAL::isa($_, "XML::LibXML::Text");} $et_element->childNodes) 5 24 29
387 5 my $et_str = $et_element->textContent;
388 5 local $@;
389 5 eval {
390 5 my $new_et = $class->parser()->parse_string(qq{<errortype code="$code">$et_str</errortype>});
391 5 $et_element = $new_et->documentElement();
392 };
393 5 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 5 5
394 0 $logger->warn($@);
395 }
396 }
397  
398 29 my ($spec, $example_data) = $class->_extract_structure($et_element);
399 29 foreach (keys %$spec) {
400 102 my $val = delete $spec->{$_};
401 102 s{^errortype}{err}; # 'errortype's are really 'err's
402 102 $spec->{$_} = $val;
403 }
404 29 $spec->{''}{elts} = [ 'err' ];
405
406 # enforce msg (code is already in here!)
407 29 push @{ $spec->{err}{attr} }, "msg";
408
409 29 $et->structure($spec);
410  
411 29 my $example = Froody::Response::String->new;
412 29 $et_element->setNodeName("err");
413 29 my $text = "<rsp status='fail'>".$et_element->toString(1)."</rsp>";
414 29 $example->set_bytes($text);
415 29 $example->structure($et);
416 29 weaken($example->{structure});
417
418 29 $et->example_response($example);
419  
420 29 return $et;
421 }
422  
423 =item parser
424  
425 This method returns the parser we're using. It's an instance of XML::LibXML.
426  
427 =cut
428  
429 {
430 14 my $parser = XML::LibXML->new;
431 14 $parser->expand_entities(1);
432 14 $parser->keep_blanks(0);
433 64 ▶ sub parser { $parser }
Subroutine parser: called CC=1 SCAR=0.0
Pod documented
434 }
435  
436 =back
437  
438 =head1 SPEC OVERVIEW
439  
440 The specs handed to C<register_spec()> should be on this form:
441  
442 <spec>
443 <methods>
444 <method ...> </method>
445 ...
446 </methods>
447 <errortypes>
448 <errortype code="error.subtype">...</errortype>
449 ...
450 </errortypes>
451 </spec>
452  
453  
454 =head2 <method>
455  
456 Each method take this form:
457  
458 <method name="foo.bar.quux" needslogin="1">
459 <description>Very short description of method's basic behaviour</description>
460 <keywords>...</keywords>
461 <arguments>...</arguments>
462 <response>...</response>
463 <errors>...</errors>
464 </method>
465  
466 =over
467  
468 =item <keywords>
469  
470 A space-separated list of keywords of the concepts touched upon
471 by this method. As an example, clockthat.events.addTags would
472 have "events tags" as its keywords. This way we can easily list
473 all methods that deals with tags, no matter where in the
474 namespace they live.
475  
476 =item <arguments>
477  
478 Each argument has two mandatory attributes: "name" and
479 "optional". The name is the name of the argument, and optional is
480 "1" if the argument is optional, or "0" otherwise.
481  
482 <argument name="api_key" optional="0">A non-optional argument</argument>
483 <argument name="quux_id" optional="1">An optional argument</argument>
484  
485 You can specify that your argument should accept a comma-separated list of values:
486  
487 <argument name="array_val" type="csv" optional="1">Don't
488 worry about description for argument type deduction now.</argument>
489  
490 =item <response>
491  
492 A well-formed XML fragment (excluding the <rsp> tag) describing
493 by example how this method will respond. This section can be
494 empty if the method does not return. When a list of elements are
495 expected, your example response B<must contain at least two>
496 elements of the same name.
497  
498 <photoset page="1" per_page="10" pages="9" total="83">
499 <name>beyond repair</name>
500 <photo photo_id="1123" />
501 <photo photo_id="2345" />
502 </photos>
503  
504 Currently we accept both a well-formed XML fragment and an
505 entity-encoded string that can be decoded to an XML fragment.
506  
507 =item <errors>
508  
509 A list of errors of this form:
510  
511 <error code="1" message="Short message">Longer error message</error>
512  
513 =back
514  
515 =head1 BUGS
516  
517 None known.
518  
519 Please report any bugs you find via the CPAN RT system.
520 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Froody>
521  
522 =head1 AUTHOR
523  
524 Copyright Fotango 2005. All rights reserved.
525  
526 Please see the main L<Froody> documentation for details of who has worked
527 on this project.
528  
529 This module is free software; you can redistribute it and/or modify it under
530 the same terms as Perl itself.
531  
532 =head1 SEE ALSO
533  
534 L<Froody>
535  
536 =cut
537  
538 14 1;
« blib/lib/Froody/Request/Apache.pm ↑ Summary blib/lib/Froody/Server.pm »