-
Notifications
You must be signed in to change notification settings - Fork 34
/
index.html
2099 lines (1906 loc) · 76.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<title>apiDoc - Inline Documentation for RESTful web APIs</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="//fonts.googleapis.com/css?family=Source+Code+Pro%7CSource+Sans+Pro:400,700" rel="stylesheet" type="text/css">
<link href="css/easy-responsive-tabs.css" rel="stylesheet" media="screen">
<link href="css/style.css" rel="stylesheet" media="screen">
<link href="img/favicon.ico" rel="icon" type="image/x-icon">
</head>
<body>
<nav class="nav-top">
<a id="forkme" href="https://github.com/apidoc/apidoc"><img src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
<ul>
<li><a href="#demo">Demo</a></li>
<li><a href="#getting-started">Getting started</a></li>
<li><a href="#examples">Examples</a></li>
<li><a href="#params">APIDOC-Params</a></li>
</ul>
</nav>
<div class="container">
<header>
<h1>APIDOC</h1>
<h2>Inline Documentation for RESTful web APIs</h2>
<h3>apiDoc creates a documentation from API annotations in your source code.</h3>
<div class="pull-left span9">
<div id="exampleTab">
<ul class="resp-tabs-list">
<li title="C#, Go, Dart, Java, JavaScript, PHP, TypeScript (all DocStyle capable languages)">Java, JavaScript, PHP, …</li>
<li title="CoffeeScript">CoffeeScript</li>
<li title="Elixir">Elixir</li>
<li title="Erlang">Erlang</li>
<li title="Perl">Perl</li>
<li title="Python">Python</li>
<li title="Ruby">Ruby</li>
<li title="Lua">Lua</li>
</ul>
<div class="resp-tabs-container">
<!-- Tab 1 -->
<div>
<pre class="example"><code>/**
* @api {get} /user/:id Request User information
* @apiName GetUser
* @apiGroup User
*
* @apiParam {Number} id Users unique ID.
*
* @apiSuccess {String} firstname Firstname of the User.
* @apiSuccess {String} lastname Lastname of the User.
*/</code></pre>
</div>
<!-- Tab CoffeeScript -->
<div>
<pre class="example"><code>###
@api {get} /user/:id Request User information
@apiName GetUser
@apiGroup User
@apiParam {Number} id Users unique ID.
@apiSuccess {String} firstname Firstname of the User.
@apiSuccess {String} lastname Lastname of the User.
###</code></pre>
</div>
<!-- Tab Elixir -->
<div>
<pre class="example"><code># {
# @api {get} /user/:id Request User information
# @apiName GetUser
# @apiGroup User
#
# @apiParam {Number} id Users unique ID.
#
# @apiSuccess {String} firstname Firstname of the User.
# @apiSuccess {String} lastname Lastname of the User.
# }</code></pre>
</div>
<!-- Tab Erlang -->
<div>
<pre class="example"><code>%{
% @api {get} /user/:id Request User information
% @apiName GetUser
% @apiGroup User
%
% @apiParam {Number} id Users unique ID.
%
% @apiSuccess {String} firstname Firstname of the User.
% @apiSuccess {String} lastname Lastname of the User.
%}</code></pre>
</div>
<!-- Tab Perl -->
<div>
<pre class="example"><code>=pod
@api {get} /user/:id Request User information
@apiName GetUser
@apiGroup User
@apiParam {Number} id Users unique ID.
@apiSuccess {String} firstname Firstname of the User.
@apiSuccess {String} lastname Lastname of the User.
=cut</code></pre>
</div>
<!-- Tab Python -->
<div>
<pre class="example"><code>"""
@api {get} /user/:id Request User information
@apiName GetUser
@apiGroup User
@apiParam {Number} id Users unique ID.
@apiSuccess {String} firstname Firstname of the User.
@apiSuccess {String} lastname Lastname of the User.
"""</code></pre>
</div>
<!-- Tab Ruby -->
<div>
<pre class="example"><code>=begin
@api {get} /user/:id Request User information
@apiName GetUser
@apiGroup User
@apiParam {Number} id Users unique ID.
@apiSuccess {String} firstname Firstname of the User.
@apiSuccess {String} lastname Lastname of the User.
=end</code></pre>
</div>
<!-- Tab Lua -->
<div>
<pre class="example"><code>--[[
@api {get} /user/:id Request User information
@apiName GetUser
@apiGroup User
@apiParam {Number} id Users unique ID.
@apiSuccess {String} firstname Firstname of the User.
@apiSuccess {String} lastname Lastname of the User.
]]</code></pre>
</div>
</div>
</div>
<p>apiDoc gives you the ability to attach a version number to an API, so that you can easily track changes between versions.</p>
</div>
</header>
<div id="main">
<aside>
<nav class="nav-main">
<ul>
<li class="nav-header"><a href="#demo">Demo</a></li>
<li class="nav-header"><a href="#getting-started">Getting started</a></li>
<li><a href="#preface">Preface</a></li>
<li><a href="#install">Install</a></li>
<li><a href="#run">Run</a></li>
<li><a href="#CLI">CLI</a></li>
<li><a href="#grunt-module">GRUNT Module</a></li>
<li><a href="#template">Template</a></li>
<li><a href="#extend">Extend</a></li>
<li><a href="#configuration">Configuration (apidoc.json)</a></li>
<li><a href="#headerfooter">Header / Footer</a></li>
<li class="nav-header"><a href="#examples">Examples</a></li>
<li><a href="#example-basic">Basic</a></li>
<li><a href="#example-inherit">Inherit</a></li>
<li><a href="#example-versioning">Versioning</a></li>
<li><a href="#example-full">Full example (all together)</a></li>
<li id="nav-main-params" class="nav-header"><a href="#params">apiDoc-Params</a></li>
<li><a href="#param-api">@api</a></li>
<li><a href="#param-api-body">@apiBody</a></li>
<li><a href="#param-api-define">@apiDefine</a></li>
<li><a href="#param-api-deprecated">@apiDeprecated</a></li>
<li><a href="#param-api-description">@apiDescription</a></li>
<li><a href="#param-api-error">@apiError</a></li>
<li><a href="#param-api-error-example">@apiErrorExample</a></li>
<li><a href="#param-api-example">@apiExample</a></li>
<li><a href="#param-api-group">@apiGroup</a></li>
<li><a href="#param-api-header">@apiHeader</a></li>
<li><a href="#param-api-header-example">@apiHeaderExample</a></li>
<li><a href="#param-api-ignore">@apiIgnore</a></li>
<li><a href="#param-api-name">@apiName</a></li>
<li><a href="#param-api-param">@apiParam</a></li>
<li><a href="#param-api-param-example">@apiParamExample</a></li>
<li><a href="#param-api-permission">@apiPermission</a></li>
<li><a href="#param-api-private">@apiPrivate</a></li>
<li><a href="#param-api-query">@apiQuery</a></li>
<li><a href="#param-api-sample-request">@apiSampleRequest</a></li>
<li><a href="#param-api-success">@apiSuccess</a></li>
<li><a href="#param-api-success-example">@apiSuccessExample</a></li>
<li><a href="#param-api-use">@apiUse</a></li>
<li><a href="#param-api-version">@apiVersion</a></li>
<li class="deprecated"><br><a href="deprecated.html">Deprecated params</a></li>
</ul>
</nav>
</aside>
<div id="content" role="main">
<!--
/* ============================================================
* Demo
* ============================================================ */
-->
<section id="demo">
<h1>Demo</h1>
<article id="demo-ouput">
<h2>This is an example documentation:</h2>
<a href="example/">
<img src="img/example.png" width="500" height="238" alt="Example screenshot" title="Example output of a generated apidoc" class="with-border">
</a>
<h3>
<a href="example/" class="button" title="demo">Go to live demo</a>
<a href="https://speakerdeck.com/rottmann/api-documentation" target="_blank" title="Introduction with a small example" class="button">See presentation</a>
</h3>
</p>
</article>
</section>
<!--
/* ============================================================
* Getting started
* ============================================================ */
-->
<section id="getting-started">
<h1>Getting started</h1>
<article id="preface">
<h2>Preface</h2>
<p>All examples in this document use the <strong>Javadoc-Style</strong> (can be used in C#, Go, Dart, Java, JavaScript, PHP, TypeScript and all other Javadoc capable languages):</p>
<pre class="example"><code>/**
* This is a comment.
*/</code></pre>
<p>For other languages use their specific multiline comment code:</p>
<p>CoffeeScript</p>
<pre class="example"><code>###
This is a comment.
###</code></pre>
<p>Elixir</p>
<pre class="example"><code>@apidoc """
This is a comment.
"""</code></pre>
<p>Erlang (% within the comment is optional)</p>
<pre class="example"><code>%{
% This is a comment.
%}</code></pre>
<p>Perl (Doxygen)</p>
<pre class="example"><code>#**
# This is a comment.
#*</code></pre>
<p>Python</p>
<pre class="example"><code>"""
This is a comment.
"""</code></pre>
<p>Ruby</p>
<pre class="example"><code>=begin
This is a comment.
=end</code></pre>
<p>Lua</p>
<pre class="example"><code>--[[
This is a comment.
--]]</code></pre>
</article>
<article id="install">
<h2>Install</h2>
<pre><code>npm install apidoc -g</code></pre>
</article>
<article id="run">
<h2>Run</h2>
<pre><code>apidoc -i src -o apidoc</code></pre>
<p>Creates an apiDoc of all files within dir <code>src</code>, using the default template, and puts all output to <code>apidoc</code> directory.</p>
<p>Without any parameter, apiDoc generates a documentation from all <code>.cs</code> <code>.dart</code> <code>.erl</code> <code>.go</code> <code>.java</code> <code>.js</code> <code>.php</code> <code>.py</code> <code>.rb</code> <code>.ts</code> files in the current dir (incl. subdirs) and writes the output to <code>./doc/</code>.</p>
</article>
<article id="CLI">
<h2>Command Line Interface</h2>
<p>Show command line parameters:</p>
<pre><code>apidoc -h</code></pre>
<p>Important parameters:</p>
<table>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="code">-c, --config</td>
<td>
Specify the path to the config file to use. (default: apidoc.json or apidoc.js in input dir)<br>
<br>
Example:<br>
<code>apidoc -c path/to/apidoc.json</code>
</td>
</tr>
<tr>
<td class="code">-e, --exclude-filters</td>
<td>
RegEx-Filter to select files / dirs that should not be parsed (many -e can be used). (default: [])<br>
<br>
Example:<br>
<code>apidoc -e node_modules</code>
</td>
</tr>
<tr>
<td class="code nowrap">-f, --file-filters</td>
<td>
RegEx-Filter to select files that should be parsed (many -f can be used). Default <code>.cs</code> <code>.dart</code> <code>.erl</code> <code>.go</code> <code>.java</code> <code>.js</code> <code>.php</code> <code>.py</code> <code>.rb</code> <code>.ts</code>.<br>
<br>
Example (parse only .js and .ts files):<br>
<code>apidoc -f ".*\\.js$" -f ".*\\.ts$"</code>
</td>
</tr>
<tr>
<td class="code">-i, --input</td>
<td>
Input / source dirname. Location of your project files.<br>
<br>
Example:<br>
<code>apidoc -i myapp/</code>
</td>
</tr>
<tr>
<td class="code">-o, --output</td>
<td>
Output dirname. Location where to put to generated documentation.<br>
<br>
Example:<br>
<code>apidoc -o apidoc/</code>
</td>
</tr>
<tr>
<td class="code">-t, --template</td>
<td>
Use template for output files. You can create and use your own template.<br>
<br>
Example:<br>
<code>apidoc -t mytemplate/</code>
</td>
</tr>
</tbody>
</table>
</article>
<article id="grunt-module">
<h2>GRUNT Module</h2>
<p>
A separate grunt module is supported, visit <a href="https://github.com/apidoc/grunt-apidoc">github.com/apidoc/grunt-apidoc</a><br>
or install via npm:
</p>
<pre><code>npm install grunt-apidoc --save-dev</code></pre>
</article>
<article id="template">
<h2>Template</h2>
<p>apiDoc include a default template which supports:
<ul>
<li>versioning: view different versions of your API</li>
<li>comparing: view changes between two versions of your API</li>
</ul>
<p><a href="example/">view default demo</a></p>
<h3>Create your own</h3>
<p>You can create your own template and use it instead of the provided one (at your own risk!)</p>
<p>View the source on <a href="https://github.com/apidoc/apidoc/tree/master/template">https://github.com/apidoc/apidoc/tree/master/template</a></p>
</article>
<article id="extend">
<h2>Extend</h2>
<p>apiDoc can be extended with your own parameters (if something is not available that you need). Look at <a href="https://github.com/apidoc/apidoc-core/tree/master/lib/parsers">lib/parsers/</a>,
<a href="https://github.com/apidoc/apidoc-core/tree/master/lib/workers">lib/workers/</a>, and <a href="https://github.com/apidoc/apidoc-core/tree/master/lib/filters">lib/filters/</a>
directories in the <a href="https://github.com/apidoc/apidoc-core">apidoc/apidoc-core</a> project for examples.
<code>parser</code> split the parameter data, <code>worker</code> processes additional functions with all found data and <code>filter</code> reduce the data to needed things.
</p>
<p>Example usage: <code>apidoc --parse-filters myFilter=pathToMyFilter/myFilter.js</code></p>
<p><strong>Or <a href="https://github.com/apidoc/apidoc">fork</a> the whole project and create a pull request to make apiDoc better.</strong></p>
</article>
<article id="configuration">
<h2>Configuration (apidoc.json)</h2>
<p>The optional <code>apidoc.json</code> in your projects root dir includes common information about your project like title, short description, version, and configuration options like <a href="#headerfooter">header / footer</a> settings or template specific options.</p>
<p><a href="source/example_full/apidoc.json">apidoc.json</a></p>
<pre><code>{
"name": "example",
"version": "0.1.0",
"description": "apiDoc basic example",
"title": "Custom apiDoc browser title",
"url" : "https://api.github.com/v1"
}</code></pre>
<p>If you use a <code>package.json</code> (e.g., in a node.js project), all <code>apidoc.json</code> settings can be done in <code>package.json</code> too, just add them under the <code>"apidoc": { }</code> parameter.</p>
<p>package.json</p>
<pre><code>{
"name": "example",
"version": "0.1.0",
"description": "apiDoc basic example",
"apidoc": {
"title": "Custom apiDoc browser title",
"url" : "https://api.github.com/v1"
}
}</code></pre>
<h3 id="configuration-settings">Settings for apidoc.json</h3>
<table>
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="code">name</td>
<td>Name of your project.<br>If no <code>apidoc.json</code> with the field exists, then apiDoc tries to determine the value from <code>package.json</code>.</td>
</tr>
<tr>
<td class="code">version</td>
<td>Version of your project.<br>If no <code>apidoc.json</code> with the field exists, then apiDoc tries to determine the value from <code>package.json</code>.</td>
</tr>
<tr>
<td class="code">description</td>
<td>Introduction of your project.<br>If no <code>apidoc.json</code> with the field exists, then apiDoc tries to determine the value from <code>package.json</code>.</td>
</tr>
<tr>
<td class="code">title</td>
<td>Browser title text.</td>
</tr>
<tr>
<td class="code">url</td>
<td>Prefix for api path (endpoints), e.g., <code>https://api.github.com/v1</code></td>
</tr>
<tr>
<td class="code" id="configuration-settings-sample-url">sampleUrl</td>
<td>If set to a URL, a form to test an api method (send a request) will be visible. If set to <code>true</code>, the form will be visible and the same URL as the current document will be used. If set to <code>false</code> or not defined, no form will be generated. See <a href="#param-api-sample-request">@apiSampleRequest</a> for finer control of where this form is generated and how.</td>
</tr>
<tr>
<td class="code" colspan="2">header</td>
</tr>
<tr>
<td class="code"> title</td>
<td>Navigation text for the included header.md file.<br>(watch <a href="#headerfooter">Header / Footer</a>)</td>
</tr>
<tr>
<td class="code"> filename</td>
<td>Filename (markdown-file) for the included header.md file.</td>
</tr>
<tr>
<td class="code" colspan="2">footer</td>
</tr>
<tr>
<td class="code"> title</td>
<td>Navigation text for the included footer.md file.</td>
</tr>
<tr>
<td class="code"> filename</td>
<td>Filename (markdown-file) for the included footer.md file.</td>
</tr>
<tr>
<td class="code">order</td>
<td>A list of api-names / group-names for ordering the output. Not defined names are automatically displayed last.<br>
<pre><code>"order": [
"Error",
"Define",
"PostTitleAndError",
"PostError"
]</code></pre>
</td>
</tr>
</tbody>
</table>
<h3 id="configuration-template-settings">Template specific settings</h3>
<p>The following settings are specific for the default template of apiDoc.</p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="code" colspan="3">template</td>
</tr>
<tr>
<td class="code"> forceLanguage</td>
<td class="code">String</td>
<td>Disable browser language auto-detection and set a specific locale.<br>
Example: <code>de</code>, <code>en</code>.<br>
View available locales <a href="https://github.com/apidoc/apidoc/tree/master/template/src/locales" target="_blank">here</a>.
</td>
</tr>
<tr>
<td class="code"> withCompare</td>
<td class="code">Boolean</td>
<td>Enable comparison with older api versions. Default: <code>true</code></td>
</tr>
<tr>
<td class="code"> withGenerator</td>
<td class="code">Boolean</td>
<td>Output the generator information at the footer. Default: <code>true</code></td>
</tr>
<tr>
<td class="code"> aloneDisplay</td>
<td class="code">Boolean</td>
<td>When clicking a menu header, only show that content on page. Default: <code>false</code></td>
</tr>
<tr>
<td class="code"> showRequiredLabels</td>
<td class="code">Boolean</td>
<td>Display "required" labels for non-optional parameters. Default: <code>false</code></td>
</tr>
</tbody>
</table>
</article>
<article id="headerfooter">
<h2>Header / Footer</h2>
<p>In your projects <code>apidoc.json</code> you can add a header and footer.</p>
<p>The title will be visible in the navigation. The filename should be a markdown textfile.</p>
<p><a href="source/example_full/apidoc.json">apidoc.json</a></p>
<pre><code>{
"header": {
"title": "My own header title",
"filename": "header.md"
},
"footer": {
"title": "My own footer title",
"filename": "footer.md"
}
}</code></pre>
</article>
</section>
<!--
/* ============================================================
* Examples
* ============================================================ */
-->
<section id="examples">
<h1>Examples</h1>
<h3>
<a href="example/" class="button" title="demo">Go to live demo</a>
<a href="https://speakerdeck.com/rottmann/api-documentation" target="_blank" title="Introduction with a small example" class="button">See presentation</a>
</h3>
<article id="example-basic">
<h2>Basic</h2>
<p>In this basic example we have a small project file and an apidoc.json.</p>
<p><a href="source/example_basic/apidoc.json">apidoc.json</a></p>
<pre><code>{
"name": "example",
"version": "0.1.0",
"description": "A basic apiDoc example"
}</code></pre>
<p>From <code>apidoc.json</code> apiDoc gets the name, version and description of your project.<br>
The file is <code>optional</code> (it depends on your template if the data is required).</p>
<p><br></p>
<p><a href="source/example_basic/example.js">example.js</a></p>
<pre><code>/**
* <code class="important">@api {get} /user/:id Request User information</code>
* <code class="important">@apiName GetUser</code>
* <code class="important">@apiGroup User</code>
*
* @apiParam {Number} id Users unique ID.
*
* @apiSuccess {String} firstname Firstname of the User.
* @apiSuccess {String} lastname Lastname of the User.
*
* @apiSuccessExample Success-Response:
* HTTP/1.1 200 OK
* {
* "firstname": "John",
* "lastname": "Doe"
* }
*
* @apiError UserNotFound The <code>id</code> of the User was not found.
*
* @apiErrorExample Error-Response:
* HTTP/1.1 404 Not Found
* {
* "error": "UserNotFound"
* }
*/</code></pre>
<p>A documentation block starts with <code>/**</code> and ends with <code>*/</code>.</p>
<p>This example describes a <code>GET</code> method to request the User information by the user's <code>id</code>.</p>
<p><code>@api {get} /user/:id Request User information</code> is mandatory, without <code>@api</code> apiDoc ignores a documentation block.</p>
<p><code>@apiName</code> must be a unique name and should always be used.<br>
Format: <i>method</i> + <i>path</i> (e.g., Get + User)</p>
<p><code>@apiGroup</code> should always be used, and is used to group related APIs together.</p>
<p>All other fields are optional, look at their description under <a href="#params">apiDoc-Params</a>.</p>
</article>
<!-- ============================================================ -->
<article id="example-inherit">
<h2>Inherit</h2>
<p>Using inherit, you can define reusable snippets of your documentation.</p>
<p><br></p>
<p><a href="source/example_inherit/apidoc.json">apidoc.json</a></p>
<pre><code>{
"name": "example-inherit",
"version": "0.1.0",
"description": "apiDoc inherit example"
}</code></pre>
<p><br></p>
<p><a href="source/example_inherit/example.js">example.js</a></p>
<pre><code>/**
* <code class="important">@apiDefine UserNotFoundError</code>
*
* @apiError UserNotFound The <code>id</code> of the User was not found.
*
* @apiErrorExample Error-Response:
* HTTP/1.1 404 Not Found
* {
* "error": "UserNotFound"
* }
*/
/**
* @api {get} /user/:id Request User information
* @apiName GetUser
* @apiGroup User
*
* @apiParam {Number} id Users unique ID.
*
* @apiSuccess {String} firstname Firstname of the User.
* @apiSuccess {String} lastname Lastname of the User.
*
* @apiSuccessExample Success-Response:
* HTTP/1.1 200 OK
* {
* "firstname": "John",
* "lastname": "Doe"
* }
*
* <code class="important">@apiUse UserNotFoundError</code>
*/
/**
* @api {put} /user/ Modify User information
* @apiName PutUser
* @apiGroup User
*
* @apiParam {Number} id Users unique ID.
* @apiParam {String} [firstname] Firstname of the User.
* @apiParam {String} [lastname] Lastname of the User.
*
* @apiSuccessExample Success-Response:
* HTTP/1.1 200 OK
*
* <code class="important">@apiUse UserNotFoundError</code>
*/</code></pre>
<p>
In this example, <code>@apiDefine</code> is used to define a block named <code>UserNotFoundError</code>,
which can be referenced repeatedly using <code>@apiUse UserNotFoundError</code>.
</p>
<p>
The complete documentation of <code>UserNotFoundError</code> will be included in both <code>GET</code> and <code>PUT</code> methods in the generated output.
</p>
<p>
To create an inheritable block, use <code>apiDefine</code>.<br>
To reference a block, use <code>apiUse</code>.
The <code>apiGroup</code> and <code>apiPermission</code> use similar syntax, but they do not inherit any parameters except for the title and description (in combination with <code>apiVersion</code>).
</p>
<p>
<strong>Inheritance only works with one parent</strong>, using multiple levels would make the inline code unreadable and changes very complex.
</p>
</article>
<!-- ============================================================ -->
<article id="example-versioning">
<h2>Versioning</h2>
<p>A useful feature provided by apiDoc is the ability to maintain the documentation for all previous versions and the latest version of the API. This makes it possible to compare a methods' version with its predecessor. Frontend Developer can thus simply see what have changed and update their code accordingly.</p>
<p>In the example, click on the dropdown box in the top right (the main version) and select <code>Compare all with predecessor</code>.</p>
<ul>
<li>The main navigation mark all changed methods with a green bar.</li>
<li>Each method shows the actual difference compare to its predecessor.</li>
<li>Green marks contents that were added (in this case title text changed and field <code>registered</code> was added).</li>
<li>Red marks contents that were removed.</li>
</ul>
<p>You can change the main version (top right) to a previous version and compare older methods with their predecessor.</p>
<p><br></p>
<p><a href="source/example_inherit/apidoc.json">apidoc.json</a></p>
<pre><code>{
"name": "example-versioning",
"version": "0.2.0",
"description": "apiDoc versioning example"
}</code></pre>
<p><br></p>
<p>In order to avoid code bloat when API documentation changes over time, it is recommended to use a separate history file named <code>_apidoc.js</code>. Before you change your documentation block, copy the old documentation to this file, apiDoc will include the historical information automatically.</p>
<p><a href="source/example_versioning/_apidoc.js">_apidoc.js</a></p>
<pre><code>/**
* @api {get} /user/:id Get User information
* <code class="important">@apiVersion 0.1.0</code>
* @apiName GetUser
* @apiGroup User
*
* @apiParam {Number} id Users unique ID.
*
* @apiSuccess {String} firstname Firstname of the User.
* @apiSuccess {String} lastname Lastname of the User.
*
* @apiSuccessExample Success-Response:
* HTTP/1.1 200 OK
* {
* "firstname": "John",
* "lastname": "Doe"
* }
*
* @apiError UserNotFound The <code>id</code> of the User was not found.
*
* @apiErrorExample Error-Response:
* HTTP/1.1 404 Not Found
* {
* "error": "UserNotFound"
* }
*/</code></pre>
<p><a href="source/example_versioning/example.js">example.js</a> (your current project file)</p>
<pre><code>/**
* @api {get} /user/:id Get User information and date of registration.
* <code class="important">@apiVersion 0.2.0</code>
* @apiName GetUser
* @apiGroup User
*
* @apiParam {Number} id Users unique ID.
*
* @apiSuccess {String} firstname Firstname of the User.
* @apiSuccess {String} lastname Lastname of the User.
* @apiSuccess {Date} registered Date of Registration.
*
* @apiSuccessExample Success-Response:
* HTTP/1.1 200 OK
* {
* "firstname": "John",
* "lastname": "Doe"
* }
*
* @apiError UserNotFound The <code>id</code> of the User was not found.
*
* @apiErrorExample Error-Response:
* HTTP/1.1 404 Not Found
* {
* "error": "UserNotFound"
* }
*/</code></pre>
<p>It is important to set the version with <code>@apiVersion</code> on every documentation block.</p>
<p><br></p>
<p>The version can be used on every block, including inherit-blocks. You don't have to change the version on an inherit-block, the parser automatically checks for the nearest predecessor.</p>
</article>
<!-- ============================================================ -->
<article id="example-full">
<h2>Full example</h2>
<p>This is a complex example with <code>inherit</code>, <code>versioning</code> file and history file <code>_apidoc.js</code>, explanation is within code and generated documentation.</p>
<p><a href="example/">View example output</a></p>
<p><br></p>
<p>All files used for this example can be found <a href='https://github.com/apidoc/apidoc/tree/master/example'>in the example folder</a></p>
</article>
</section>
<!--
/* ============================================================
* Params
* ============================================================ */
-->
<section id="params">
<h1>apiDoc-Params</h1>
<p>Structure parameter like:</p>
<ul>
<li><code>@apiDefine</code></li>
</ul>
<p>is used to define a reusable documentation block. This block can be included in normal api documentation blocks. Using <code>@apiDefine</code> allows you to better organize complex documentation and avoid duplicating recurrent blocks.</p>
<p>A defined block can have all params (like <code>@apiParam</code>), <strong>except other defined blocks</strong>.</p>
<article id="param-api">
<h2>@api</h2>
<pre><code>@api {method} path title</code></pre>
<p><strong>Required!</strong></p>
<p>Without that indicator, the apiDoc parser ignores the documentation block.</p>
<p>The only exception are documentation blocks defined by <code>@apiDefine</code>, they do not require <code>@api</code>.</p>
<p>Usage: <code>@api {get} /user/:id Users unique ID.</code></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="code">method</td>
<td>
Request method name: <code>DELETE</code>, <code>GET</code>, <code>POST</code>, <code>PUT</code>, …<br>
More info <a href="http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods">Wikipedia HTTP-Request methods</a>
</td>
</tr>
<tr>
<td class="code">path</td>
<td>Request Path.</td>
</tr>
<tr>
<td class="code">title</td>
<td>A short title. (used for navigation and article header)</td>
</tr>
</tbody>
</table>
<p>Example:</p>
<pre class="example"><code>/**
* @api {get} /user/:id Get user info
*/</code></pre>
</article>
<!-- ============================================================ -->
<article id="param-api-body">
<h2>@apiBody</h2>
<pre><code>@apiBody [{type}] [field=defaultValue] [description]</code></pre>
<p>Describe the request body passed to your API-Method.</p>
<p>Usage: <code>@apiBody {String} lastname User lastname.</code></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="code">{type}<span class="label label-optional">optional</span></td>
<td>
Parameter type, e.g., <code>{Boolean}</code>, <code>{Number}</code>, <code>{String}</code>, <code>{Object}</code>, <code>{String[]}</code> (array of strings), …
</td>
</tr>
<tr>
<td class="code">{type{size}}<span class="label label-optional">optional</span></td>
<td>
Information about the size of the variable.<br>
<code>{string{..5}}</code> a string that has max 5 chars.<br>
<code>{string{2..5}}</code> a string that has min. 2 chars and max 5 chars.<br>
<code>{number{100-999}}</code> a number between 100 and 999.<br>
</td>
</tr>
<tr>
<td class="code">{type=allowedValues}<span class="label label-optional">optional</span></td>
<td>
Information about allowed values of the variable.<br>
<code>{string="small"}</code> a string that can only contain the word "small" (a constant).<br>
<code>{string="small","huge"}</code> a string that can contain the words "small" or "huge".<br>
<code>{number=1,2,3,99}</code> a number with allowed values of 1, 2, 3 and 99.<br>
<br>
Can be combined with size:<br>
<code>{string {..5}="small","huge"}</code> a string that has max 5 chars and only contain the words "small" or "huge".<br>
</td>
</tr>
<tr>
<td class="code">field</td>
<td>
Fieldname.
</td>
</tr>
<tr>
<td class="code">[field]</td>
<td>
Fieldname with brackets define the variable as optional.
</td>
</tr>
<tr>
<td class="code">field[nestedField]</td>
<td>
Mandatory nested field.
</td>
</tr>
<tr>
<td class="code">=defaultValue<span class="label label-optional">optional</span></td>
<td>
The parameters' default value.
</td>
</tr>
<tr>
<td class="code">description<span class="label label-optional">optional</span></td>
<td>
Description of the field.
</td>
</tr>
</tbody>
</table>
<p>Example:</p>
<pre class="example"><code>/**
* @api {post} /user/
* @apiBody {String} [firstname] Optional Firstname of the User.
* @apiBody {String} lastname Mandatory Lastname.
* @apiBody {String} country="DE" Mandatory with default value "DE".
* @apiBody {Number} [age=18] Optional Age with default 18.
*
* @apiBody (Login) {String} pass Only logged-in users can post this.
* In generated documentation a separate
* "Login" Block will be generated.
*
* @apiBody {Object} [address] Optional nested address object.
* @apiBody {String} [address[street]] Optional street and number.
* @apiBody {String} [address[zip]] Optional zip code.
* @apiBody {String} [address[city]] Optional city.
*/</code></pre>
</article>
<!-- ============================================================ -->
<article id="param-api-define">
<h2>@apiDefine</h2>
<pre><code>@apiDefine name [title]
[description]</code></pre>
<p>Defines a documentation block to be embedded within <code>@api</code> blocks or in an api function like <code>@apiPermission</code>.</p>
<p><code>@apiDefine</code> can only be used once per block</p>
<p>By using <code>@apiUse</code> a defined block will be imported, or with the name the title and description will be used.</p>
<p>Usage: <code>@apiDefine MyError</code></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="code">name</td>
<td>
Unique name for the block / value.<br>
Same name with different <code>@apiVersion</code> can be defined.
</td>
</tr>
<tr>
<td class="code">title <span class="label label-optional">optional</span></td>
<td>
A short title. Only used for named functions like <code>@apiPermission</code> or <code>@apiParam (name)</code>.
</td>
</tr>
<tr>
<td class="code">description <span class="label label-optional">optional</span></td>
<td>
Detailed description starts at the next line, multiple lines can be used. Only used for named functions like <code>@apiPermission</code>.
</td>
</tr>
</tbody>
</table>
<p>Example:</p>
<pre class="example"><code>/**
* @apiDefine MyError
* @apiError UserNotFound The <code>id</code> of the User was not found.