forked from kfsm/restapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
restapi.tex
202 lines (162 loc) · 3.84 KB
/
restapi.tex
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
\documentclass{report}
\usepackage{tikz}
\usetikzlibrary{arrows,automata}
\usepackage{amsmath}
\usepackage{amssymb}
\setlength{\parindent}{0cm}
\setlength{\parskip}{0.75em}
\input{restful}
\begin{document}
\title{xxx}
\author{}
\maketitle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Introduction}
%%
%% short description about the service.
\section{Rationale}
tbd.
%%
%%
\section{Terms of Service}
tbd.
%%
%%
\section{Environments}
\restful{
\env{dev}{xxx}
\env{stage}{xxx}
\env{live}{xxx}
}
\section{Common behavior}
%%
%% list of media types consumed / produces by service
\subsection{Media Types}
\subsubsection{Consumes}
\restful{
\mimetype{application/ld+json}
{tbd}
}
\subsubsection{Produces}
\restful{
\mimetype{application/json}
{tbd}
}
\subsection{Protocol}
%%
%% service protocols, transfer requirements, etc.
\subsubsection{Schema}
tbd.
%%
%% list of common request parameters (e.g. headers)
\subsubsection{Request}
\restful{
\head{Accept}
{tbd}
\head{Content-Type}
{tbd}
}
%%
%% list of common response parameters
\subsubsection{Response}
\restful{
\head{Content-Type}
{tbd.}
}
%%
%% list of plausible response codes
\subsubsection{Status}
\restful{
\httpcode{200} {operation successfully completed}
\httpcode{201} {operation successfully completed, and resource was created}
\httpcode{406} {the supplied request does not conform API specification, requested attributes are not known}
\httpcode{500} {for any abnormally terminated requests}
}
%%
%% api authentication schema
\subsection{Authentication}
void
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Resource model}
\section{Rationale}
tbd
\section{Definition}
%%
%% a definition of the resource (domain objects),
%% specifies request / response structures
\subsection{TBD}
tbd.
\resource{
\attr{@id}{string}{tbd}
\attr{@type}{string}{tbd}
\attr{title}{string}{tbd}
}
\paragraph{example} inline example
\subsubsection{example}
\begin{verbatim}
code example
\end{verbatim}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Interface}
%%
%% interface summary including end-point tempates
\section{Summary}
tbd.
\routes{
\uri{/collection/:abc/resource/:def}
{tbd}
}
%%
%% detailed resource specification
\section{End-points}
%%
%% end-point specification
\subsection{/collection/:abc/resource/:def}
tbd.
%%
%% method specification
%% - method id
%% - path template
%% - description
%% - preconditions, parameters, etc (use \sep to build list)
%% - postcondition (use \sep to build list)
%% - expected status codes
\request{GET} {/collection/:abc/resource/:def}
{tbd}
{Accept: application/json \sep q = string}
{Content-Type: application/json}
{\status{200} \sep \status{404} \sep \status{500}}
\example{example}
\begin{verbatim}
curl -v -X GET http://localhost:8080/collection/x/resource/y
* About to connect() to localhost port 8080 (#0)
* Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /collection/x/resource/y HTTP/1.1
> User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
> Host: localhost:8080
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: MochiWeb/1.0 (Any of you quaids got a smint?)
< Date: Fri, 01 Jun 2012 20:01:36 GMT
< Content-Length: 175
< Conten-Type: application/json
<
< []
* Connection #0 to host localhost left intact
* Closing connection #0
\end{verbatim}
\end{document}