mirror of
https://github.com/ambieco/scribe.git
synced 2026-04-30 02:36:15 +08:00
urlParam: update tests
This commit is contained in:
@@ -188,7 +188,6 @@ class TestController extends Controller
|
||||
{
|
||||
return [
|
||||
'{id}' => $id,
|
||||
'APP_ENV' => getenv('APP_ENV'),
|
||||
'header' => request()->header('header'),
|
||||
'queryParam' => request()->query('queryParam'),
|
||||
'bodyParam' => request()->get('bodyParam'),
|
||||
|
||||
@@ -117,12 +117,24 @@
|
||||
"type": "text",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "yet_another_param.name",
|
||||
"value": "consequatur",
|
||||
"type": "text",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "even_more_param",
|
||||
"value": [],
|
||||
"type": "text",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "even_more_param.*",
|
||||
"value": 11613.31890586,
|
||||
"type": "text",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "book.name",
|
||||
"value": "consequatur",
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"header": [
|
||||
{
|
||||
"key": "Accept",
|
||||
"value": "application/json"
|
||||
"value": "application\/json"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
@@ -51,7 +51,13 @@
|
||||
},
|
||||
{
|
||||
"key": "yet_another_param",
|
||||
"value": [],
|
||||
"value": {},
|
||||
"type": "text",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "yet_another_param.name",
|
||||
"value": "consequatur",
|
||||
"type": "text",
|
||||
"enabled": true
|
||||
},
|
||||
@@ -61,6 +67,12 @@
|
||||
"type": "text",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "even_more_param.*",
|
||||
"value": 11613.31890586,
|
||||
"type": "text",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "book.name",
|
||||
"value": "consequatur",
|
||||
|
||||
@@ -32,20 +32,23 @@ It can also be multiple lines long.
|
||||
> Example request:
|
||||
|
||||
```bash
|
||||
curl -X GET -G "http://localhost/api/withDescription" \
|
||||
curl -X GET \
|
||||
-G "http://localhost/api/withDescription" \
|
||||
-H "Authorization: customAuthToken" \
|
||||
-H "Custom-Header: NotSoCustom"
|
||||
```
|
||||
|
||||
```javascript
|
||||
const url = new URL("http://localhost/api/withDescription");
|
||||
const url = new URL(
|
||||
"http://localhost/api/withDescription"
|
||||
);
|
||||
|
||||
let headers = {
|
||||
"Authorization": "customAuthToken",
|
||||
"Custom-Header": "NotSoCustom",
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
|
||||
fetch(url, {
|
||||
method: "GET",
|
||||
@@ -73,20 +76,23 @@ null
|
||||
> Example request:
|
||||
|
||||
```bash
|
||||
curl -X GET -G "http://localhost/api/withResponseTag" \
|
||||
curl -X GET \
|
||||
-G "http://localhost/api/withResponseTag" \
|
||||
-H "Authorization: customAuthToken" \
|
||||
-H "Custom-Header: NotSoCustom"
|
||||
```
|
||||
|
||||
```javascript
|
||||
const url = new URL("http://localhost/api/withResponseTag");
|
||||
const url = new URL(
|
||||
"http://localhost/api/withResponseTag"
|
||||
);
|
||||
|
||||
let headers = {
|
||||
"Authorization": "customAuthToken",
|
||||
"Custom-Header": "NotSoCustom",
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
|
||||
fetch(url, {
|
||||
method: "GET",
|
||||
@@ -122,31 +128,38 @@ fetch(url, {
|
||||
> Example request:
|
||||
|
||||
```bash
|
||||
curl -X GET -G "http://localhost/api/withBodyParameters" \
|
||||
curl -X GET \
|
||||
-G "http://localhost/api/withBodyParameters" \
|
||||
-H "Authorization: customAuthToken" \
|
||||
-H "Custom-Header: NotSoCustom" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"user_id":9,"room_id":"consequatur","forever":false,"another_one":11613.31890586,"yet_another_param":{},"even_more_param":[],"book":{"name":"consequatur","author_id":17,"pages_count":17},"ids":[17],"users":[{"first_name":"John","last_name":"Doe"}]}'
|
||||
-d '{"user_id":9,"room_id":"consequatur","forever":false,"another_one":11613.31890586,"yet_another_param":{"name":"consequatur"},"even_more_param":[11613.31890586],"book":{"name":"consequatur","author_id":17,"pages_count":17},"ids":[17],"users":[{"first_name":"John","last_name":"Doe"}]}'
|
||||
|
||||
```
|
||||
|
||||
```javascript
|
||||
const url = new URL("http://localhost/api/withBodyParameters");
|
||||
const url = new URL(
|
||||
"http://localhost/api/withBodyParameters"
|
||||
);
|
||||
|
||||
let headers = {
|
||||
"Authorization": "customAuthToken",
|
||||
"Custom-Header": "NotSoCustom",
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json",
|
||||
}
|
||||
};
|
||||
|
||||
let body = {
|
||||
"user_id": 9,
|
||||
"room_id": "consequatur",
|
||||
"forever": false,
|
||||
"another_one": 11613.31890586,
|
||||
"yet_another_param": {},
|
||||
"even_more_param": [],
|
||||
"yet_another_param": {
|
||||
"name": "consequatur"
|
||||
},
|
||||
"even_more_param": [
|
||||
11613.31890586
|
||||
],
|
||||
"book": {
|
||||
"name": "consequatur",
|
||||
"author_id": 17,
|
||||
@@ -183,22 +196,23 @@ null
|
||||
`GET api/withBodyParameters`
|
||||
|
||||
#### Body Parameters
|
||||
|
||||
Parameter | Type | Status | Description
|
||||
--------- | ------- | ------- | ------- | -----------
|
||||
user_id | integer | required | The id of the user.
|
||||
room_id | string | optional | The id of the room.
|
||||
forever | boolean | optional | Whether to ban the user forever.
|
||||
another_one | number | optional | Just need something here.
|
||||
yet_another_param | object | required |
|
||||
even_more_param | array | optional |
|
||||
book.name | string | optional |
|
||||
book.author_id | integer | optional |
|
||||
book[pages_count] | integer | optional |
|
||||
ids.* | integer | optional |
|
||||
users.*.first_name | string | optional | The first name of the user.
|
||||
users.*.last_name | string | optional | The last name of the user.
|
||||
|
||||
room_id | string | optional | The id of the room.
|
||||
forever | boolean | optional | Whether to ban the user forever.
|
||||
another_one | number | optional | Just need something here.
|
||||
yet_another_param | object | required | Some object params.
|
||||
yet_another_param.name | string | required | Subkey in the object param.
|
||||
even_more_param | array | optional | Some array params.
|
||||
even_more_param.* | float | optional | Subkey in the array param.
|
||||
book.name | string | optional |
|
||||
book.author_id | integer | optional |
|
||||
book[pages_count] | integer | optional |
|
||||
ids.* | integer | optional |
|
||||
users.*.first_name | string | optional | The first name of the user.
|
||||
users.*.last_name | string | optional | The last name of the user.
|
||||
|
||||
<!-- END_a25cb3b490fa579d7d77b386bbb7ec03 -->
|
||||
|
||||
<!-- START_5c545aa7f913d84b23ac4cfefc1de659 -->
|
||||
@@ -206,29 +220,33 @@ Parameter | Type | Status | Description
|
||||
> Example request:
|
||||
|
||||
```bash
|
||||
curl -X GET -G "http://localhost/api/withQueryParameters?location_id=consequatur&user_id=me&page=4&filters=consequatur&url_encoded=%2B+%5B%5D%26%3D" \
|
||||
curl -X GET \
|
||||
-G "http://localhost/api/withQueryParameters?location_id=consequatur&user_id=me&page=4&filters=consequatur&url_encoded=%2B+%5B%5D%26%3D" \
|
||||
-H "Authorization: customAuthToken" \
|
||||
-H "Custom-Header: NotSoCustom"
|
||||
```
|
||||
|
||||
```javascript
|
||||
const url = new URL("http://localhost/api/withQueryParameters");
|
||||
const url = new URL(
|
||||
"http://localhost/api/withQueryParameters"
|
||||
);
|
||||
|
||||
let params = {
|
||||
"location_id": "consequatur",
|
||||
"user_id": "me",
|
||||
"page": "4",
|
||||
"filters": "consequatur",
|
||||
"url_encoded": "+ []&=",
|
||||
};
|
||||
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]));
|
||||
let params = {
|
||||
"location_id": "consequatur",
|
||||
"user_id": "me",
|
||||
"page": "4",
|
||||
"filters": "consequatur",
|
||||
"url_encoded": "+ []&=",
|
||||
};
|
||||
Object.keys(params)
|
||||
.forEach(key => url.searchParams.append(key, params[key]));
|
||||
|
||||
let headers = {
|
||||
"Authorization": "customAuthToken",
|
||||
"Custom-Header": "NotSoCustom",
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
|
||||
fetch(url, {
|
||||
method: "GET",
|
||||
@@ -266,20 +284,23 @@ Parameter | Status | Description
|
||||
> Example request:
|
||||
|
||||
```bash
|
||||
curl -X GET -G "http://localhost/api/withAuthTag" \
|
||||
curl -X GET \
|
||||
-G "http://localhost/api/withAuthTag" \
|
||||
-H "Authorization: customAuthToken" \
|
||||
-H "Custom-Header: NotSoCustom"
|
||||
```
|
||||
|
||||
```javascript
|
||||
const url = new URL("http://localhost/api/withAuthTag");
|
||||
const url = new URL(
|
||||
"http://localhost/api/withAuthTag"
|
||||
);
|
||||
|
||||
let headers = {
|
||||
"Authorization": "customAuthToken",
|
||||
"Custom-Header": "NotSoCustom",
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
|
||||
fetch(url, {
|
||||
method: "GET",
|
||||
@@ -307,20 +328,23 @@ null
|
||||
> Example request:
|
||||
|
||||
```bash
|
||||
curl -X POST "http://localhost/api/withMultipleResponseTagsAndStatusCode" \
|
||||
curl -X POST \
|
||||
"http://localhost/api/withMultipleResponseTagsAndStatusCode" \
|
||||
-H "Authorization: customAuthToken" \
|
||||
-H "Custom-Header: NotSoCustom"
|
||||
```
|
||||
|
||||
```javascript
|
||||
const url = new URL("http://localhost/api/withMultipleResponseTagsAndStatusCode");
|
||||
const url = new URL(
|
||||
"http://localhost/api/withMultipleResponseTagsAndStatusCode"
|
||||
);
|
||||
|
||||
let headers = {
|
||||
"Authorization": "customAuthToken",
|
||||
"Custom-Header": "NotSoCustom",
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
|
||||
fetch(url, {
|
||||
method: "POST",
|
||||
@@ -357,4 +381,74 @@ fetch(url, {
|
||||
|
||||
<!-- END_55f321056bfc0de7269ac70e24eb84be -->
|
||||
|
||||
#Other😎
|
||||
|
||||
|
||||
<!-- START_33e62c07bc6d7286628b18c0e046ebea -->
|
||||
## api/echoesUrlParameters/{param}-{param2}/{param3?}
|
||||
> Example request:
|
||||
|
||||
```bash
|
||||
curl -X GET \
|
||||
-G "http://localhost/api/echoesUrlParameters/4-consequatur/?something=consequatur" \
|
||||
-H "Authorization: customAuthToken" \
|
||||
-H "Custom-Header: NotSoCustom"
|
||||
```
|
||||
|
||||
```javascript
|
||||
const url = new URL(
|
||||
"http://localhost/api/echoesUrlParameters/4-consequatur/"
|
||||
);
|
||||
|
||||
let params = {
|
||||
"something": "consequatur",
|
||||
};
|
||||
Object.keys(params)
|
||||
.forEach(key => url.searchParams.append(key, params[key]));
|
||||
|
||||
let headers = {
|
||||
"Authorization": "customAuthToken",
|
||||
"Custom-Header": "NotSoCustom",
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
};
|
||||
|
||||
fetch(url, {
|
||||
method: "GET",
|
||||
headers: headers,
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(json => console.log(json));
|
||||
```
|
||||
|
||||
|
||||
> Example response (200):
|
||||
|
||||
```json
|
||||
{
|
||||
"param": "4",
|
||||
"param2": "consequatur",
|
||||
"param3": null,
|
||||
"param4": null
|
||||
}
|
||||
```
|
||||
|
||||
### HTTP Request
|
||||
`GET api/echoesUrlParameters/{param}-{param2}/{param3?}`
|
||||
|
||||
#### URL Parameters
|
||||
|
||||
Parameter | Status | Description
|
||||
--------- | ------- | ------- | -------
|
||||
param | required |
|
||||
param2 | optional |
|
||||
param4 | optional |
|
||||
#### Query Parameters
|
||||
|
||||
Parameter | Status | Description
|
||||
--------- | ------- | ------- | -----------
|
||||
something | optional |
|
||||
|
||||
<!-- END_33e62c07bc6d7286628b18c0e046ebea -->
|
||||
|
||||
|
||||
|
||||
@@ -29,17 +29,20 @@ Welcome to the generated API reference.
|
||||
> Example request:
|
||||
|
||||
```bash
|
||||
curl -X GET -G "http://localhost/api/users" \
|
||||
curl -X GET \
|
||||
-G "http://localhost/api/users" \
|
||||
-H "Accept: application/json"
|
||||
```
|
||||
|
||||
```javascript
|
||||
const url = new URL("http://localhost/api/users");
|
||||
const url = new URL(
|
||||
"http://localhost/api/users"
|
||||
);
|
||||
|
||||
let headers = {
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
|
||||
fetch(url, {
|
||||
method: "GET",
|
||||
@@ -70,17 +73,20 @@ fetch(url, {
|
||||
> Example request:
|
||||
|
||||
```bash
|
||||
curl -X GET -G "http://localhost/api/users/create" \
|
||||
curl -X GET \
|
||||
-G "http://localhost/api/users/create" \
|
||||
-H "Accept: application/json"
|
||||
```
|
||||
|
||||
```javascript
|
||||
const url = new URL("http://localhost/api/users/create");
|
||||
const url = new URL(
|
||||
"http://localhost/api/users/create"
|
||||
);
|
||||
|
||||
let headers = {
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
|
||||
fetch(url, {
|
||||
method: "GET",
|
||||
|
||||
@@ -29,17 +29,20 @@ Welcome to the generated API reference.
|
||||
> Example request:
|
||||
|
||||
```bash
|
||||
curl -X GET -G "http://localhost/api/users" \
|
||||
curl -X GET \
|
||||
-G "http://localhost/api/users" \
|
||||
-H "Accept: application/json"
|
||||
```
|
||||
|
||||
```javascript
|
||||
const url = new URL("http://localhost/api/users");
|
||||
const url = new URL(
|
||||
"http://localhost/api/users"
|
||||
);
|
||||
|
||||
let headers = {
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
|
||||
fetch(url, {
|
||||
method: "GET",
|
||||
@@ -70,17 +73,20 @@ fetch(url, {
|
||||
> Example request:
|
||||
|
||||
```bash
|
||||
curl -X GET -G "http://localhost/api/users/create" \
|
||||
curl -X GET \
|
||||
-G "http://localhost/api/users/create" \
|
||||
-H "Accept: application/json"
|
||||
```
|
||||
|
||||
```javascript
|
||||
const url = new URL("http://localhost/api/users/create");
|
||||
const url = new URL(
|
||||
"http://localhost/api/users/create"
|
||||
);
|
||||
|
||||
let headers = {
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
|
||||
fetch(url, {
|
||||
method: "GET",
|
||||
@@ -111,17 +117,20 @@ fetch(url, {
|
||||
> Example request:
|
||||
|
||||
```bash
|
||||
curl -X POST "http://localhost/api/users" \
|
||||
curl -X POST \
|
||||
"http://localhost/api/users" \
|
||||
-H "Accept: application/json"
|
||||
```
|
||||
|
||||
```javascript
|
||||
const url = new URL("http://localhost/api/users");
|
||||
const url = new URL(
|
||||
"http://localhost/api/users"
|
||||
);
|
||||
|
||||
let headers = {
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
|
||||
fetch(url, {
|
||||
method: "POST",
|
||||
@@ -145,17 +154,20 @@ fetch(url, {
|
||||
> Example request:
|
||||
|
||||
```bash
|
||||
curl -X GET -G "http://localhost/api/users/1" \
|
||||
curl -X GET \
|
||||
-G "http://localhost/api/users/1" \
|
||||
-H "Accept: application/json"
|
||||
```
|
||||
|
||||
```javascript
|
||||
const url = new URL("http://localhost/api/users/1");
|
||||
const url = new URL(
|
||||
"http://localhost/api/users/1"
|
||||
);
|
||||
|
||||
let headers = {
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
|
||||
fetch(url, {
|
||||
method: "GET",
|
||||
@@ -186,17 +198,20 @@ fetch(url, {
|
||||
> Example request:
|
||||
|
||||
```bash
|
||||
curl -X GET -G "http://localhost/api/users/1/edit" \
|
||||
curl -X GET \
|
||||
-G "http://localhost/api/users/1/edit" \
|
||||
-H "Accept: application/json"
|
||||
```
|
||||
|
||||
```javascript
|
||||
const url = new URL("http://localhost/api/users/1/edit");
|
||||
const url = new URL(
|
||||
"http://localhost/api/users/1/edit"
|
||||
);
|
||||
|
||||
let headers = {
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
|
||||
fetch(url, {
|
||||
method: "GET",
|
||||
@@ -227,17 +242,20 @@ fetch(url, {
|
||||
> Example request:
|
||||
|
||||
```bash
|
||||
curl -X PUT "http://localhost/api/users/1" \
|
||||
curl -X PUT \
|
||||
"http://localhost/api/users/1" \
|
||||
-H "Accept: application/json"
|
||||
```
|
||||
|
||||
```javascript
|
||||
const url = new URL("http://localhost/api/users/1");
|
||||
const url = new URL(
|
||||
"http://localhost/api/users/1"
|
||||
);
|
||||
|
||||
let headers = {
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
|
||||
fetch(url, {
|
||||
method: "PUT",
|
||||
@@ -263,17 +281,20 @@ fetch(url, {
|
||||
> Example request:
|
||||
|
||||
```bash
|
||||
curl -X DELETE "http://localhost/api/users/1" \
|
||||
curl -X DELETE \
|
||||
"http://localhost/api/users/1" \
|
||||
-H "Accept: application/json"
|
||||
```
|
||||
|
||||
```javascript
|
||||
const url = new URL("http://localhost/api/users/1");
|
||||
const url = new URL(
|
||||
"http://localhost/api/users/1"
|
||||
);
|
||||
|
||||
let headers = {
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
|
||||
fetch(url, {
|
||||
method: "DELETE",
|
||||
|
||||
Reference in New Issue
Block a user