Skip to content

Commit cef6e01

Browse files
committed
DOC: Autogenerate and update documentation
1 parent bad14d1 commit cef6e01

File tree

1 file changed

+62
-49
lines changed

1 file changed

+62
-49
lines changed

docs/helpers/REST.md

Lines changed: 62 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,25 @@ title: REST
1414
REST helper allows to send additional requests to the REST API during acceptance tests.
1515
[Axios][1] library is used to perform requests.
1616

17+
18+
1719
## Configuration
1820

1921
Type: [object][4]
2022

2123
### Properties
2224

23-
- `endpoint` **[string][3]?** API base URL
24-
- `prettyPrintJson` **[boolean][6]?** pretty print json for response/request on console logs.
25-
- `printCurl` **[boolean][6]?** print cURL request on console logs. False by default.
26-
- `timeout` **[number][5]?** timeout for requests in milliseconds. 10000ms by default.
27-
- `defaultHeaders` **[object][4]?** a list of default headers.
28-
- `httpAgent` **[object][4]?** create an agent with SSL certificate
29-
- `onRequest` **[function][7]?** an async function which can update request object.
30-
- `onResponse` **[function][7]?** an async function which can update response object.
31-
- `maxUploadFileSize` **[number][5]?** set the max content file size in MB when performing api calls.
25+
* `endpoint` **[string][3]?** API base URL
26+
* `prettyPrintJson` **[boolean][6]?** pretty print json for response/request on console logs.
27+
* `printCurl` **[boolean][6]?** print cURL request on console logs. False by default.
28+
* `timeout` **[number][5]?** timeout for requests in milliseconds. 10000ms by default.
29+
* `defaultHeaders` **[object][4]?** a list of default headers.
30+
* `httpAgent` **[object][4]?** create an agent with SSL certificate
31+
* `onRequest` **[function][7]?** an async function which can update request object.
32+
* `onResponse` **[function][7]?** an async function which can update response object.
33+
* `maxUploadFileSize` **[number][5]?** set the max content file size in MB when performing api calls.
34+
35+
3236

3337
## Example
3438

@@ -87,34 +91,34 @@ Send REST requests by accessing `_executeRequest` method:
8791

8892
```js
8993
this.helpers['REST']._executeRequest({
90-
url,
91-
data,
92-
})
94+
url,
95+
data,
96+
});
9397
```
9498

9599
## Methods
96100

97101
### Parameters
98102

99-
- `config`  
103+
* `config`  
100104

101-
### \_executeRequest
105+
### _executeRequest
102106

103107
Executes axios request
104108

105109
#### Parameters
106110

107-
- `request` **any** 
111+
* `request` **any** 
108112

109113
Returns **[Promise][2]<any>** response
110114

111-
### \_url
115+
### _url
112116

113117
Generates url based on format sent (takes endpoint + url if latter lacks 'http')
114118

115119
#### Parameters
116120

117-
- `url` **any**&#x20;
121+
* `url` **any**&#x20;
118122

119123
### amBearerAuthenticated
120124

@@ -127,28 +131,28 @@ I.amBearerAuthenticated(secret('heregoestoken'))
127131

128132
#### Parameters
129133

130-
- `accessToken` **([string][3] | CodeceptJS.Secret)** Bearer access token
134+
* `accessToken` **([string][3] | CodeceptJS.Secret)** Bearer access token
131135

132136
### haveRequestHeaders
133137

134138
Sets request headers for all requests of this test
135139

136140
#### Parameters
137141

138-
- `headers` **[object][4]** headers list
142+
* `headers` **[object][4]** headers list
139143

140144
### sendDeleteRequest
141145

142146
Sends DELETE request to API.
143147

144148
```js
145-
I.sendDeleteRequest('/api/users/1')
149+
I.sendDeleteRequest('/api/users/1');
146150
```
147151

148152
#### Parameters
149153

150-
- `url` **any**&#x20;
151-
- `headers` **[object][4]** the headers object to be sent. By default, it is sent as an empty object
154+
* `url` **any**&#x20;
155+
* `headers` **[object][4]** the headers object to be sent. By default, it is sent as an empty object
152156

153157
Returns **[Promise][2]<any>** response
154158

@@ -157,14 +161,14 @@ Returns **[Promise][2]<any>** response
157161
Sends DELETE request to API with payload.
158162

159163
```js
160-
I.sendDeleteRequestWithPayload('/api/users/1', { author: 'john' })
164+
I.sendDeleteRequestWithPayload('/api/users/1', { author: 'john' });
161165
```
162166

163167
#### Parameters
164168

165-
- `url` **any**&#x20;
166-
- `payload` **any** the payload to be sent. By default it is sent as an empty object
167-
- `headers` **[object][4]** the headers object to be sent. By default, it is sent as an empty object
169+
* `url` **any**&#x20;
170+
* `payload` **any** the payload to be sent. By default it is sent as an empty object
171+
* `headers` **[object][4]** the headers object to be sent. By default, it is sent as an empty object
168172

169173
Returns **[Promise][2]<any>** response
170174

@@ -173,13 +177,13 @@ Returns **[Promise][2]<any>** response
173177
Send GET request to REST API
174178

175179
```js
176-
I.sendGetRequest('/api/users.json')
180+
I.sendGetRequest('/api/users.json');
177181
```
178182

179183
#### Parameters
180184

181-
- `url` **any**&#x20;
182-
- `headers` **[object][4]** the headers object to be sent. By default, it is sent as an empty object
185+
* `url` **any**&#x20;
186+
* `headers` **[object][4]** the headers object to be sent. By default, it is sent as an empty object
183187

184188
Returns **[Promise][2]<any>** response
185189

@@ -188,13 +192,13 @@ Returns **[Promise][2]<any>** response
188192
Send HEAD request to REST API
189193

190194
```js
191-
I.sendHeadRequest('/api/users.json')
195+
I.sendHeadRequest('/api/users.json');
192196
```
193197

194198
#### Parameters
195199

196-
- `url` **any**&#x20;
197-
- `headers` **[object][4]** the headers object to be sent. By default, it is sent as an empty object
200+
* `url` **any**&#x20;
201+
* `headers` **[object][4]** the headers object to be sent. By default, it is sent as an empty object
198202

199203
Returns **[Promise][2]<any>** response
200204

@@ -203,17 +207,18 @@ Returns **[Promise][2]<any>** response
203207
Sends PATCH request to API.
204208

205209
```js
206-
I.sendPatchRequest('/api/users.json', { email: '[email protected]' })
210+
I.sendPatchRequest('/api/users.json', { "email": "[email protected]" });
207211

208212
// To mask the payload in logs
209-
I.sendPatchRequest('/api/users.json', secret({ email: '[email protected]' }))
213+
I.sendPatchRequest('/api/users.json', secret({ "email": "[email protected]" }));
214+
210215
```
211216

212217
#### Parameters
213218

214-
- `url` **[string][3]**&#x20;
215-
- `payload` **any** the payload to be sent. By default it is sent as an empty object
216-
- `headers` **[object][4]** the headers object to be sent. By default it is sent as an empty object
219+
* `url` **[string][3]**&#x20;
220+
* `payload` **any** the payload to be sent. By default it is sent as an empty object
221+
* `headers` **[object][4]** the headers object to be sent. By default it is sent as an empty object
217222

218223
Returns **[Promise][2]<any>** response
219224

@@ -222,17 +227,18 @@ Returns **[Promise][2]<any>** response
222227
Sends POST request to API.
223228

224229
```js
225-
I.sendPostRequest('/api/users.json', { email: '[email protected]' })
230+
I.sendPostRequest('/api/users.json', { "email": "[email protected]" });
226231

227232
// To mask the payload in logs
228-
I.sendPostRequest('/api/users.json', secret({ email: '[email protected]' }))
233+
I.sendPostRequest('/api/users.json', secret({ "email": "[email protected]" }));
234+
229235
```
230236

231237
#### Parameters
232238

233-
- `url` **any**&#x20;
234-
- `payload` **any** the payload to be sent. By default, it is sent as an empty object
235-
- `headers` **[object][4]** the headers object to be sent. By default, it is sent as an empty object
239+
* `url` **any**&#x20;
240+
* `payload` **any** the payload to be sent. By default, it is sent as an empty object
241+
* `headers` **[object][4]** the headers object to be sent. By default, it is sent as an empty object
236242

237243
Returns **[Promise][2]<any>** response
238244

@@ -241,17 +247,18 @@ Returns **[Promise][2]<any>** response
241247
Sends PUT request to API.
242248

243249
```js
244-
I.sendPutRequest('/api/users.json', { email: '[email protected]' })
250+
I.sendPutRequest('/api/users.json', { "email": "[email protected]" });
245251

246252
// To mask the payload in logs
247-
I.sendPutRequest('/api/users.json', secret({ email: '[email protected]' }))
253+
I.sendPutRequest('/api/users.json', secret({ "email": "[email protected]" }));
254+
248255
```
249256

250257
#### Parameters
251258

252-
- `url` **[string][3]**&#x20;
253-
- `payload` **any** the payload to be sent. By default it is sent as an empty object
254-
- `headers` **[object][4]** the headers object to be sent. By default it is sent as an empty object
259+
* `url` **[string][3]**&#x20;
260+
* `payload` **any** the payload to be sent. By default it is sent as an empty object
261+
* `headers` **[object][4]** the headers object to be sent. By default it is sent as an empty object
255262

256263
Returns **[Promise][2]<any>** response
257264

@@ -260,17 +267,23 @@ Returns **[Promise][2]<any>** response
260267
Set timeout for the request
261268

262269
```js
263-
I.setRequestTimeout(10000) // In milliseconds
270+
I.setRequestTimeout(10000); // In milliseconds
264271
```
265272

266273
#### Parameters
267274

268-
- `newTimeout` **[number][5]** timeout in milliseconds
275+
* `newTimeout` **[number][5]** timeout in milliseconds
269276

270277
[1]: https://github.com/axios/axios
278+
271279
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
280+
272281
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
282+
273283
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
284+
274285
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
286+
275287
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
288+
276289
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function

0 commit comments

Comments
 (0)