0% fanden dieses Dokument nützlich (0 Abstimmungen)
6 Ansichten18 Seiten

Rest Api

Rest api pdf

Hochgeladen von

saimankhatiwada9611
Copyright
© All Rights Reserved
Wir nehmen die Rechte an Inhalten ernst. Wenn Sie vermuten, dass dies Ihr Inhalt ist, beanspruchen Sie ihn hier.
Verfügbare Formate
Als PDF, TXT herunterladen oder online auf Scribd lesen
0% fanden dieses Dokument nützlich (0 Abstimmungen)
6 Ansichten18 Seiten

Rest Api

Rest api pdf

Hochgeladen von

saimankhatiwada9611
Copyright
© All Rights Reserved
Wir nehmen die Rechte an Inhalten ernst. Wenn Sie vermuten, dass dies Ihr Inhalt ist, beanspruchen Sie ihn hier.
Verfügbare Formate
Als PDF, TXT herunterladen oder online auf Scribd lesen

The rest-api package

Dennis Klein
[Link]@[Link]

v1.4 from 2020/12/04

1 Introduction
A package to discribe a REST API for documentation.

2 Usage
GET Request with parameter
\ b e g i n { apiRoute }{ g e t }{/ a p i / s t o r a g e /\{ i d \}}{ g e t s p e c i f i c
s t o r a g e with i d }
\ begin { routeParameter }
\ routeParamItem { i d }{ i d o f s t o r a g e }
\ end { r o u t e P a r a m e t e r }
\ b e g i n { r o u t e R e s p o n s e }{ a p p l i c a t i o n / j s o n }
\ b e g i n { r o u t e R e s p o n s e I t e m }{200}{ ok }
\ b e g i n { routeResponseItemBody }
{
” id ” : 867654678 ,
”name” : ” Apfelmus ” ,
” count ” : 25
}
\ end { routeResponseItemBody }
\ end { r o u t e R e s p o n s e I t e m }
\ b e g i n { r o u t e R e s p o n s e I t e m }{404}{ e r r o r :
s t o r a g e not found }
\ b e g i n { routeResponseItemBody }
{
” message ” : ” s t o r a g e with i d ’ 1 1 ’ not found ! ”
}
\ end { routeResponseItemBody }
\ end { r o u t e R e s p o n s e I t e m }
\ end { r o u t e R e s p o n s e }
\ end { apiRoute }

1
GET Request without parameter
\ b e g i n { apiRoute }{ g e t }{/ a p i / s t o r a g e /}{ g e t a l i s t o f a l l
storage ’ s}
\ begin { routeParameter }
\ noRouteParameter {no parameter }
\ end { r o u t e P a r a m e t e r }
\ b e g i n { r o u t e R e s p o n s e }{ a p p l i c a t i o n / j s o n }
\ b e g i n { r o u t e R e s p o n s e I t e m }{200}{ ok }
\ b e g i n { routeResponseItemBody }
[
{
” id ” : 867654678 ,
”name” : ” Apfelmus ” ,
” count ” : 25
},
{
” id ” : 342523 ,
”name” : ” Birnenmus ” ,
” count ” : 1
},
...
]
\ end { routeResponseItemBody }
\ end { r o u t e R e s p o n s e I t e m }
\ end { r o u t e R e s p o n s e }
\ end { apiRoute }

GET Request without parameter and response


\ b e g i n { apiRoute }{ g e t }{/ a p i / s t o r a g e /}{}
\ begin { routeParameter }
\ noRouteParameter {no parameter }
\ end { r o u t e P a r a m e t e r }
\ b e g i n { r o u t e R e s p o n s e }{ a p p l i c a t i o n / j s o n }
\ noRouteResponse {no r e s p o n s e }
\ end { r o u t e R e s p o n s e }
\ end { apiRoute }

POST Request
\ b e g i n { apiRoute }{ p o s t }{/ a p i / s t o r a g e /}{ c r e a t e a new s t o r a g e }
\ begin { routeParameter }
\ noRouteParameter {no parameter }
\ end { r o u t e P a r a m e t e r }

2
\ b e g i n { r o u t e R e q u e s t }{ a p p l i c a t i o n / j s o n }
\ b e g i n { routeRequestBody }
{
”name” : ” Apfelmus ” ,
” count ” : 25
}
\ end { routeRequestBody }
\ end { r o u t e R e q u e s t }
\ b e g i n { r o u t e R e s p o n s e }{ a p p l i c a t i o n / j s o n }
\ b e g i n { r o u t e R e s p o n s e I t e m }{200}{ ok }
\ b e g i n { routeResponseItemBody }
{
” id ” : 867654678 ,
”name” : ” Apfelmus ” ,
” count ” : 25
}
\ end { routeResponseItemBody }
\ end { r o u t e R e s p o n s e I t e m }
\ end { r o u t e R e s p o n s e }
\ end { apiRoute }

PUT Request
\ b e g i n { apiRoute }{ put }{/ a p i / s t o r a g e /\{ i d \}}{ change a
e x i s t i n g s t o r a g e with i d }
\ begin { routeParameter }
\ routeParamItem { i d }{ i d o f s t o r a g e }
\ end { r o u t e P a r a m e t e r }
\ b e g i n { r o u t e R e q u e s t }{ a p p l i c a t i o n / j s o n }
\ b e g i n { routeRequestBody }
{
” id ” : 867654678 ,
”name” : ” Apfelmus ” ,
” count ” : 255
}
\ end { routeRequestBody }
\ end { r o u t e R e q u e s t }
\ b e g i n { r o u t e R e s p o n s e }{ a p p l i c a t i o n / j s o n }
\ b e g i n { r o u t e R e s p o n s e I t e m }{200}{ ok }
\ b e g i n { routeResponseItemBody }
{
” id ” : 867654678 ,
”name” : ” Apfelmus ” ,
” count ” : 255
}

3
\ end { routeResponseItemBody }
\ end { r o u t e R e s p o n s e I t e m }
\ b e g i n { r o u t e R e s p o n s e I t e m }{404}{ e r r o r :
s t o r a g e not found }
\ b e g i n { routeResponseItemBody }
{
” message ” : ” s t o r a g e with i d ’ 1 1 ’ not found ! ”
}
\ end { routeResponseItemBody }
\ end { r o u t e R e s p o n s e I t e m }
\ end { r o u t e R e s p o n s e }
\ end { apiRoute }

DELETE Request
\ b e g i n { apiRoute }{ d e l e t e }{/ a p i / s t o r a g e /\{ i d \}}{ remove a
s t o r a g e with i d }
\ begin { routeParameter }
\ routeParamItem { i d }{ i d o f s t o r a g e }
\ end { r o u t e P a r a m e t e r }
\ b e g i n { r o u t e R e s p o n s e }{ a p p l i c a t i o n / j s o n }
\ b e g i n { r o u t e R e s p o n s e I t e m }{200}{ ok }

\ end { r o u t e R e s p o n s e I t e m }
\ b e g i n { r o u t e R e s p o n s e I t e m }{404}{ e r r o r :
s t o r a g e not found }
\ b e g i n { routeResponseItemBody }
{
” message ” : ” s t o r a g e with i d ’ 1 1 ’ not found ! ”
}
\ end { routeResponseItemBody }
\ end { r o u t e R e s p o n s e I t e m }
\ end { r o u t e R e s p o n s e }
\ end { apiRoute }

DELETE Request xml


\ b e g i n { apiRoute }{ d e l e t e }{/ a p i / s t o r a g e /\{ i d \}}{
remove a s t o r a g e with i d }
\ begin { routeParameter }
\ routeParamItem { i d }{ i d o f s t o r a g e }
\ end { r o u t e P a r a m e t e r }
\ b e g i n { r o u t e R e s p o n s e }{ a p p l i c a t i o n /xml}
\ b e g i n { r o u t e R e s p o n s e I t e m }{200}{ ok }

4
\ end { r o u t e R e s p o n s e I t e m }
\ b e g i n { r o u t e R e s p o n s e I t e m }{404}{
e r r o r : s t o r a g e not found }
\ begin {
routeResponseItemBody }
<message>
s t o r a g e with i d ’ 1 1 ’ not found !
</message>
\ end { routeResponseItemBody }
\ end { r o u t e R e s p o n s e I t e m }
\ end { r o u t e R e s p o n s e }
\ end { apiRoute }

2.1 Usercallable macros and environments


\getGetColor Return the main color for routes with get method.
\getGetBorderColor Return the border color for routes with get method.
\getGetLightColor Return the background color for routes with get method.
\getPostColor Return the main color for routes with post method.
\getPostBorderColor Return the border color for routes with post method.
\getPostLightColor Return the background color for routes with post method.
\getPutColor Return the main color for routes with put method.
\getPutBorderColor Return the border color for routes with put method.
\getPutLightColor Return the background color for routes with put method.
\getDeleteColor Return the main color for routes with delete method.
\getDeleteBorderColor Return the border color for routes with delete method.
\getDeleteLightColor Return the background color for routes with delete method.
\noBreakRoute Set \routeBreakValue true.
\breakRoute Set \routeBreakValue false.
apiRoute Describe an endpoint with path, method and describtion. Contains other envi-
ronments with further information.
routeRequest Describe the content type of the request. Contains the request body.
routeParameter Describe the path parameter. Contains a list of \routeParamItem commands. If
no paramters excists you can use the command \noRouteParameter.
\routeParamItem Describe a parameter with name and describtion.
\noRouteParameter Show a text e.g. ’no parameter’.
routeResponse Describe the content type of the response. Contains a list of routeResponseItem
environments or the command \noRouteResponse.
\noRouteResponse Show a text e.g. ’no response’.
routeResponseItem Describe the the http status code with describtion. Contains the response body.

2.2 Helper macros


\routeBreakValue Return true or false to enable/disable noBreak of a route.
\methodColor Return the main color of the current route.

5
\methodLightColor Return the background color of the current route.
\methodBorderColor Return the border color of the current route.
\methodJson Set the color scheme and language with
lstset for the listings of the current route to json.
\methodXml Set the color scheme and language with
lstset for the listings of the current route to xml.

3 Implementation
this is my first package
(c) Dennis Klein
This program can be redistributed and/or modified under the terms of the LaTeX
Project Public License Distributed from CTAN archives in directory macros/la-
tex/base/[Link].
1 \NeedsTeXFormat{LaTeX2e}
2 \ProvidesPackage{restapi}[2020/02/18 REST API package]
3 \RequirePackage[T1]{fontenc}
4 \RequirePackage{tabularx,colortbl}
5 \RequirePackage{transparent}
6 \RequirePackage{xcolor}
7 \RequirePackage{color}
8 \RequirePackage{xifthen, xstring}
9 \RequirePackage{tikz}
10 \RequirePackage[framemethod=tikz]{mdframed}
11 \RequirePackage{array}
12 \RequirePackage{verbatim}
13 \RequirePackage{listings}

14 \definecolor{getBlue}{HTML}{1391FF}
15 \definecolor{getBlueBorder}{HTML}{61affe}
16 \definecolor{getLightBlue}{HTML}{ECF6FF}

\getGetColor
17 \newcommand{\getGetColor}{getBlue}

\getGetBorderColor
18 \newcommand{\getGetBorderColor}{getBlueBorder}

\getGetLightColor
19 \newcommand{\getGetLightColor}{getLightBlue}

20 \definecolor{postGreen}{HTML}{009D77}
21 \definecolor{postGreenBorder}{HTML}{49CC97}
22 \definecolor{postLightGreen}{HTML}{EBF7F4}

\getPostColor
23 \newcommand{\getPostColor}{postGreen}

6
\getPostBorderColor
24 \newcommand{\getPostBorderColor}{postGreenBorder}

\getPostLightColor
25 \newcommand{\getPostLightColor}{postLightGreen}

26 \definecolor{putOrange}{HTML}{E97500}
27 \definecolor{putOrangeBorder}{HTML}{fca130}
28 \definecolor{putLightOrange}{HTML}{FEF4EB}

\getPutColor
29 \newcommand{\getPutColor}{putOrange}

\getPutBorderColor
30 \newcommand{\getPutBorderColor}{putOrangeBorder}

\getPutLightColor
31 \newcommand{\getPutLightColor}{putLightOrange}

32 \definecolor{deleteRed}{HTML}{CF3030}
33 \definecolor{deleteRedBorder}{HTML}{f93e3e}
34 \definecolor{deleteLightRed}{HTML}{FBEEEE}

\getDeleteColor
35 \newcommand{\getDeleteColor}{deleteRed}

\getDeleteBorderColor
36 \newcommand{\getDeleteBorderColor}{deleteRedBorder}

\getDeleteLightColor
37 \newcommand{\getDeleteLightColor}{deleteLightRed}

color definitions for json


38 \colorlet{punct}{black}
39 \definecolor{background}{HTML}{EEEEEE}
40 \colorlet{delimGet}{\getGetColor}
41 \colorlet{numbGet}{delimGet}
42 \colorlet{delimPost}{\getPostColor}
43 \colorlet{numbPost}{delimPost}
44 \colorlet{delimPut}{\getPutColor}
45 \colorlet{numbPut}{delimPut}
46 \colorlet{delimDelete}{\getDeleteColor}
47 \colorlet{numbDelete}{delimDelete}

json language defintions


48 \lstdefinelanguage{jsonGet}{
49 basicstyle=\small\ttfamily\color{black},
50 numberstyle=\small\color{black},
51 keywordstyle=\color{black},

7
52 commentstyle=\color{black},
53 stringstyle=\color{black},
54 frame=L,
55 framesep=8pt,
56 framerule=2pt,
57 xleftmargin=50pt,
58 xrightmargin=0pt,
59 rulesep=0pt,
60 backgroundcolor=\color{white},
61 numbersep=8pt,
62 tabsize=4,
63 showstringspaces=false,
64 breaklines=true,
65 literate=
66 *{0}{{{\color{numbGet}0}}}{1}
67 {1}{{{\color{numbGet}1}}}{1}
68 {2}{{{\color{numbGet}2}}}{1}
69 {3}{{{\color{numbGet}3}}}{1}
70 {4}{{{\color{numbGet}4}}}{1}
71 {5}{{{\color{numbGet}5}}}{1}
72 {6}{{{\color{numbGet}6}}}{1}
73 {7}{{{\color{numbGet}7}}}{1}
74 {8}{{{\color{numbGet}8}}}{1}
75 {9}{{{\color{numbGet}9}}}{1}
76 {:}{{{\color{punct}{:}}}}{1}
77 {,}{{{\color{punct}{,}}}}{1}
78 {\{}{{{\color{delimGet}{\{}}}}{1}
79 {\}}{{{\color{delimGet}{\}}}}}{1}
80 {[}{{{\color{delimGet}{[}}}}{1}
81 {]}{{{\color{delimGet}{]}}}}{1},
82 }
83 \lstdefinelanguage{jsonPost}{
84 basicstyle=\small\ttfamily\color{black},
85 numberstyle=\small\color{black},
86 keywordstyle=\color{black},
87 commentstyle=\color{black},
88 stringstyle=\color{black},
89 frame=L,
90 framesep=8pt,
91 framerule=2pt,
92 xleftmargin=50pt,
93 xrightmargin=0pt,
94 rulesep=0pt,
95 backgroundcolor=\color{white},
96 numbersep=8pt,
97 tabsize=4,
98 showstringspaces=false,
99 breaklines=true,
100 literate=
101 *{0}{{{\color{numbPost}0}}}{1}

8
102 {1}{{{\color{numbPost}1}}}{1}
103 {2}{{{\color{numbPost}2}}}{1}
104 {3}{{{\color{numbPost}3}}}{1}
105 {4}{{{\color{numbPost}4}}}{1}
106 {5}{{{\color{numbPost}5}}}{1}
107 {6}{{{\color{numbPost}6}}}{1}
108 {7}{{{\color{numbPost}7}}}{1}
109 {8}{{{\color{numbPost}8}}}{1}
110 {9}{{{\color{numbPost}9}}}{1}
111 {:}{{{\color{punct}{:}}}}{1}
112 {,}{{{\color{punct}{,}}}}{1}
113 {\{}{{{\color{delimPost}{\{}}}}{1}
114 {\}}{{{\color{delimPost}{\}}}}}{1}
115 {[}{{{\color{delimPost}{[}}}}{1}
116 {]}{{{\color{delimPost}{]}}}}{1},
117 }
118 \lstdefinelanguage{jsonPut}{
119 basicstyle=\small\ttfamily\color{black},
120 numberstyle=\small\color{black},
121 keywordstyle=\color{black},
122 commentstyle=\color{black},
123 stringstyle=\color{black},
124 frame=L,
125 framesep=8pt,
126 framerule=2pt,
127 xleftmargin=50pt,
128 xrightmargin=0pt,
129 rulesep=0pt,
130 backgroundcolor=\color{white},
131 numbersep=8pt,
132 tabsize=4,
133 showstringspaces=false,
134 breaklines=true,
135 literate=
136 *{0}{{{\color{numbPut}0}}}{1}
137 {1}{{{\color{numbPut}1}}}{1}
138 {2}{{{\color{numbPut}2}}}{1}
139 {3}{{{\color{numbPut}3}}}{1}
140 {4}{{{\color{numbPut}4}}}{1}
141 {5}{{{\color{numbPut}5}}}{1}
142 {6}{{{\color{numbPut}6}}}{1}
143 {7}{{{\color{numbPut}7}}}{1}
144 {8}{{{\color{numbPut}8}}}{1}
145 {9}{{{\color{numbPut}9}}}{1}
146 {:}{{{\color{punct}{:}}}}{1}
147 {,}{{{\color{punct}{,}}}}{1}
148 {\{}{{{\color{delimPut}{\{}}}}{1}
149 {\}}{{{\color{delimPut}{\}}}}}{1}
150 {[}{{{\color{delimPut}{[}}}}{1}
151 {]}{{{\color{delimPut}{]}}}}{1},

9
152 }
153 \lstdefinelanguage{jsonDelete}{
154 basicstyle=\small\ttfamily\color{black},
155 numberstyle=\small\color{black},
156 keywordstyle=\color{black},
157 commentstyle=\color{black},
158 stringstyle=\color{black},
159 frame=L,
160 framesep=8pt,
161 framerule=2pt,
162 xleftmargin=50pt,
163 xrightmargin=0pt,
164 rulesep=0pt,
165 backgroundcolor=\color{white},
166 numbersep=8pt,
167 tabsize=4,
168 showstringspaces=false,
169 breaklines=true,
170 literate=
171 *{0}{{{\color{numbDelete}0}}}{1}
172 {1}{{{\color{numbDelete}1}}}{1}
173 {2}{{{\color{numbDelete}2}}}{1}
174 {3}{{{\color{numbDelete}3}}}{1}
175 {4}{{{\color{numbDelete}4}}}{1}
176 {5}{{{\color{numbDelete}5}}}{1}
177 {6}{{{\color{numbDelete}6}}}{1}
178 {7}{{{\color{numbDelete}7}}}{1}
179 {8}{{{\color{numbDelete}8}}}{1}
180 {9}{{{\color{numbDelete}9}}}{1}
181 {:}{{{\color{punct}{:}}}}{1}
182 {,}{{{\color{punct}{,}}}}{1}
183 {\{}{{{\color{delimDelete}{\{}}}}{1}
184 {\}}{{{\color{delimDelete}{\}}}}}{1}
185 {[}{{{\color{delimDelete}{[}}}}{1}
186 {]}{{{\color{delimDelete}{]}}}}{1},
187 }

xml language defintions


188 \lstdefinelanguage{xmlGet}{
189 basicstyle=\small\ttfamily\color{black},
190 numberstyle=\small\color{numbGet},
191 keywordstyle=\color{black},
192 commentstyle=\color{black},
193 stringstyle=\color{black},
194 frame=L,
195 framesep=8pt,
196 framerule=2pt,
197 xleftmargin=50pt,
198 xrightmargin=0pt,
199 rulesep=0pt,

10
200 backgroundcolor=\color{white},
201 numbersep=8pt,
202 tabsize=4,
203 showstringspaces=false,
204 breaklines=false,
205 morestring=[b]",
206 morestring=[s]{>}{<},
207 morecomment=[s]{<?}{?>},
208 identifierstyle=\color{numbGet},
209 }
210 \lstdefinelanguage{xmlPost}{
211 basicstyle=\small\ttfamily\color{black},
212 numberstyle=\small\color{numbPost},
213 keywordstyle=\color{black},
214 commentstyle=\color{black},
215 stringstyle=\color{black},
216 frame=L,
217 framesep=8pt,
218 framerule=2pt,
219 xleftmargin=50pt,
220 xrightmargin=0pt,
221 rulesep=0pt,
222 backgroundcolor=\color{white},
223 numbersep=8pt,
224 tabsize=4,
225 showstringspaces=false,
226 breaklines=false,
227 morestring=[b]",
228 morestring=[s]{>}{<},
229 morecomment=[s]{<?}{?>},
230 identifierstyle=\color{numbPost},
231 }
232 \lstdefinelanguage{xmlPut}{
233 basicstyle=\small\ttfamily\color{black},
234 numberstyle=\small\color{numbPut},
235 keywordstyle=\color{black},
236 commentstyle=\color{black},
237 stringstyle=\color{black},
238 frame=L,
239 framesep=8pt,
240 framerule=2pt,
241 xleftmargin=50pt,
242 xrightmargin=0pt,
243 rulesep=0pt,
244 backgroundcolor=\color{white},
245 numbersep=8pt,
246 tabsize=4,
247 showstringspaces=false,
248 breaklines=false,
249 morestring=[b]",

11
250 morestring=[s]{>}{<},
251 morecomment=[s]{<?}{?>},
252 stringstyle=\color{black},
253 identifierstyle=\color{numbPut},
254 }
255 \lstdefinelanguage{xmlDelete}{
256 basicstyle=\small\ttfamily\color{black},
257 numberstyle=\small\color{numbDelete},
258 keywordstyle=\color{black},
259 commentstyle=\color{black},
260 stringstyle=\color{black},
261 frame=L,
262 framesep=8pt,
263 framerule=2pt,
264 xleftmargin=50pt,
265 xrightmargin=0pt,
266 rulesep=0pt,
267 backgroundcolor=\color{white},
268 numbersep=8pt,
269 tabsize=4,
270 showstringspaces=false,
271 breaklines=false,
272 morestring=[b]",
273 morestring=[s]{>}{<},
274 morecomment=[s]{<?}{?>},
275 identifierstyle=\color{numbDelete},
276 }

apiRoute frame style defintion


277 \mdfdefinestyle{mystyle}{
278 linecolor=\methodBorderColor,
279 backgroundcolor=\methodLightColor,
280 skipabove=0pt,
281 linewidth=1.5pt,
282 skipbelow=0pt,
283 innertopmargin=0pt,
284 innerbottommargin=-3pt,
285 innerrightmargin=0pt,
286 innerleftmargin=0pt,
287 leftmargin=0pt,
288 rightmargin=0pt,
289 nobreak=true
290 }

\bodyFormat
291 \newcommand{\bodyFormat}{json}

\routeBreakValue
292 \newcommand{\routeBreakValue}{true}

12
\noBreakRoute
293 \newcommand{\noBreakRoute}

294 {
295 \renewcommand{\routeBreakValue}{true}
296 }

\breakRoute
297 \newcommand{\breakRoute}

298 {
299 \renewcommand{\routeBreakValue}{false}
300 }

\methodColor
301 \newcommand{\methodColor}{getBlue}

\methodLightColor
302 \newcommand{\methodLightColor}{getLightBlue}

\methodBorderColor
303 \newcommand{\methodBorderColor}{getBlueBorder}

\methodJson
304 \newcommand{\methodJson}

305 {
306 \lstset{language=jsonGet,rulecolor=\color{\methodColor}}
307 }

\methodXml
308 \newcommand{\methodXml}

309 {
310 \lstset{language=xmlGet,rulecolor=\color{\methodColor}}
311 }

apiRoute
312 \newenvironment{apiRoute}[3]
313 {
314 \global\let\saved@CT@arc@\CT@arc@
315 \newcommand{\method}{#1}
316 \newcommand{\urlPath}{#2}
317 \newcommand{\routeDescription}{#3}
318
319 \ifthenelse{\equal{\method}{get}}
320 {
321 \renewcommand{\methodColor}{\getGetColor}
322 \renewcommand{\methodLightColor}{\getGetLightColor}

13
323 \renewcommand{\methodBorderColor}{\getGetBorderColor}
324 \renewcommand{\methodJson}
325 {
326 \colorlet{delimGet}{\methodColor}
327 \colorlet{numbGet}{delimGet}
328 \lstset{language=jsonGet,rulecolor=\color{\methodColor}}
329 }
330 \renewcommand{\methodXml}
331 {
332 \colorlet{delimGet}{\methodColor}
333 \colorlet{numbGet}{delimGet}
334 \lstset{language=xmlGet,rulecolor=\color{\methodColor}}
335 }
336 }
337 {}
338
339 \ifthenelse{\equal{\method}{post}}
340 {
341 \renewcommand{\methodColor}{\getPostColor}
342 \renewcommand{\methodLightColor}{\getPostLightColor}
343 \renewcommand{\methodBorderColor}{\getPostBorderColor}
344 \renewcommand{\methodJson}
345 {
346 \colorlet{delimPost}{\methodColor}
347 \colorlet{numbPost}{delimPost}
348 \lstset{language=jsonPost,rulecolor=\color{\methodColor}}
349 }
350 \renewcommand{\methodXml}
351 {
352 \colorlet{delimPost}{\methodColor}
353 \colorlet{numbPost}{delimPost}
354 \lstset{language=xmlPost,rulecolor=\color{\methodColor}}
355 }
356 }
357 {}
358
359 \ifthenelse{\equal{\method}{put}}
360 {
361 \renewcommand{\methodColor}{\getPutColor}
362 \renewcommand{\methodLightColor}{\getPutLightColor}
363 \renewcommand{\methodBorderColor}{\getPutBorderColor}
364 \renewcommand{\methodJson}
365 {
366 \colorlet{delimPut}{\methodColor}
367 \colorlet{numbPut}{delimPut}
368 \lstset{language=jsonPut,rulecolor=\color{\methodColor}}
369 }
370 \renewcommand{\methodXml}
371 {
372 \colorlet{delimPut}{\methodColor}

14
373 \colorlet{numbPut}{delimPut}
374 \lstset{language=xmlPut,rulecolor=\color{\methodColor}}
375 }
376 }
377 {}
378 \ifthenelse{\equal{\method}{delete}}
379 {
380 \renewcommand{\methodColor}{\getDeleteColor}
381 \renewcommand{\methodLightColor}{\getDeleteLightColor}
382 \renewcommand{\methodBorderColor}{\getDeleteBorderColor}
383 \renewcommand{\methodJson}
384 {
385 \colorlet{delimDelete}{\methodColor}
386 \colorlet{numbDelete}{delimDelete}
387 \lstset{language=jsonDelete,rulecolor=\color{\methodColor}}
388 }
389 \renewcommand{\methodXml}
390 {
391 \colorlet{delimDelete}{\methodColor}
392 \colorlet{numbDelete}{delimDelete}
393 \lstset{language=xmlDelete,rulecolor=\color{\methodColor}}
394 }
395 }
396 {}
397
398 \ifthenelse{\equal{\routeDescription}{}}
399 {
400 \newcommand{\printDescription}{}
401 }
402 {
403 \newcommand{\printDescription}
404 {
405 \rowcolor{\methodLightColor}
406 & \textit{\routeDescription} \\
407 }
408
409 }
410
411
412 \begingroup
413 \setlength{\parindent}{0em}
414 \begin{mdframed}[style=mystyle,nobreak=\routeBreakValue]
415 \begin{tabularx}{\textwidth}{p{1.6cm} X}
416 \rowcolor{\methodLightColor}
417
418 \cellcolor{\methodColor}
419 \centering
420 \textcolor{white}{\textbf{\textsc{\method}}}
421 & \textbf{\urlPath} \\
422

15
423 \printDescription
424
425 \rowcolor{\methodLightColor} & \\
426 \end{tabularx}
427 }

428 {
429 \end{mdframed}
430 \endgroup
431 \global\let\CT@arc@\saved@CT@arc@
432 }

routeRequest
433 \newenvironment{routeRequest}[1]
434 {
435 \renewcommand{\bodyFormat}{#1}
436
437 \arrayrulecolor{\methodColor}
438
439 \begin{tabularx}{\textwidth}{X l}
440 \rowcolor{\methodLightColor!20}
441 \textbf{Body} & #1 \\ \hline
442 \end{tabularx}
443 \vspace{1ex}
444 }

445 {
446 \bigskip
447 }
448 \lstnewenvironment{routeRequestBody}
449 {
450 \IfSubStr{\bodyFormat}{xml}{\methodXml}{\methodJson}
451 }
452 {}

routeParameter
453 \newenvironment{routeParameter}
454 {
455 \newcommand{\routeParamItem}[2]
456 {
457 \rowcolor{\methodLightColor} ##1 & ##2 \\
458 }
459 \newcommand{\noRouteParameter}[1]
460 {
461 \small{\textit{##1}}
462 }
463 %\vspace{-0.61em}
464
465 \arrayrulecolor{\methodColor}
466

16
467 \begin{tabularx}{\textwidth}{X}
468 \rowcolor{\methodLightColor!20}
469 \textbf{Parameter} \\ \hline
470 \end{tabularx}
471
472 \tabularx{\textwidth}{l X}
473 }

474 {
475 \endtabularx
476 }

routeResponse
477 \newenvironment{routeResponse}[1]
478 {
479 \renewcommand{\bodyFormat}{#1}
480
481 \newcommand{\noRouteResponse}[1]
482 {
483 \begin{tabularx}{\textwidth}{X}
484 \rowcolor{\methodLightColor}
485 \small{\textit{##1}} \\
486 \end{tabularx}
487 }
488
489 \arrayrulecolor{\methodColor}
490 \begin{tabularx}{\textwidth}{X l}
491 \rowcolor{\methodLightColor!20}
492 \textbf{Response} & #1 \\ \hline
493 \end{tabularx}
494 }

495 {}

routeResponseItem
496 \newenvironment{routeResponseItem}[2]
497 {
498 \begin{tabularx}{\textwidth}{l X}
499 \textbf{#1} & #2 \\
500 \end{tabularx}
501 }

502 {
503 \medskip
504 }
505 \lstnewenvironment{routeResponseItemBody}
506 {
507 \vspace{-1.4em}
508 \IfSubStr{\bodyFormat}{xml}{\methodXml}{\methodJson}
509 }

17
510 {}
511 \endinput
End of file ‘[Link]’.

18

Das könnte Ihnen auch gefallen