more faithful error description in openapi spec
This commit is contained in:
parent
e2464d22a5
commit
b036eb057e
1 changed files with 26 additions and 8 deletions
|
@ -38,30 +38,48 @@ info:
|
|||
# Errors
|
||||
|
||||
The API uses standard HTTP status codes to indicate the success or failure
|
||||
of the API call. The body of the response will be JSON in the following
|
||||
formats.
|
||||
of the API call.
|
||||
|
||||
```
|
||||
HTTP 1.1 404 Not Found
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"error": "Account not found" // error debug message
|
||||
"errorCode": 1
|
||||
"error": "Account not found"
|
||||
}
|
||||
```
|
||||
|
||||
Validation errors benefit from a more detailed error type and return the HTTP `400 Bad Request` status code.
|
||||
We provide error codes for [a growing number of cases](https://github.com/Chocobozzz/PeerTube/blob/develop/shared/models/server/server-error-code.enum.ts),
|
||||
but it is still optional.
|
||||
|
||||
### Validation errors
|
||||
|
||||
Each parameter is evaluated on its own against a set of rules before the route validator
|
||||
proceeds with potential testing involving parameter combinations. Errors coming from Validation
|
||||
errors appear earlier and benefit from a more detailed error type:
|
||||
|
||||
```
|
||||
HTTP 1.1 400 Bad Request
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"errors": {
|
||||
"id": { // where 'id' is the name of the parameter concerned by the error.
|
||||
"value": "a117eb-c6a9-4756-bb09-2a956239f", // value that triggered the error.
|
||||
"msg": "Should have an valid id", // error debug message
|
||||
"id": { //
|
||||
"value": "a117eb-c6a9-4756-bb09-2a956239f",
|
||||
"msg": "Should have a valid id",
|
||||
"param": "id",
|
||||
"location": "params" // 'params', 'body', 'header', 'query' or 'cookies'
|
||||
"location": "params"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Where `id` is the name of the field concerned by the error, within the route definition.
|
||||
`errors.<field>.location` can be either 'params', 'body', 'header', 'query' or 'cookies', and
|
||||
`errors.<field>.value` reports the value that didn't pass validation whose `errors.<field>.msg`
|
||||
is about.
|
||||
|
||||
# Rate limits
|
||||
|
||||
We are rate-limiting all endpoints of PeerTube's API. Custom values can be set by administrators:
|
||||
|
|
Loading…
Reference in a new issue