docs: add laravel validation errors to openapi

This commit is contained in:
b1ek 2024-08-30 08:45:45 +10:00
parent 73f7072b7f
commit e28348cfbf
Signed by: blek
GPG Key ID: 14546221E3595D0C
1 changed files with 66 additions and 18 deletions

View File

@ -16,9 +16,6 @@ paths:
content:
application/json:
schema:
type: object
properties:
user:
type: object
properties:
last_name:
@ -56,6 +53,12 @@ paths:
schema:
type: string
example: 'bad_password'
422:
description: Validation error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
/api/users/login:
post:
tags:
@ -86,10 +89,13 @@ paths:
| key | val |
| --- | --- |
| `bad_email` | email is not a valid email |
| `bad_password` | authentication unsuccessful; this means that there is either no user with this email, or password doesn't match |
This error also might be sent by laravel if your body is corrupted
422:
description: Validation error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
/api/users/reset:
post:
tags:
@ -112,6 +118,12 @@ paths:
200:
description: |-
The password is reset
422:
description: Validation error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
/api/users/private/list:
get:
@ -147,8 +159,12 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/User'
400:
description: Invalid ID
422:
description: Validation error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
404:
description: User not found
/api/users/private/edit/{id}:
@ -166,6 +182,12 @@ paths:
responses:
200:
description: OK
422:
description: Validation error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
requestBody:
description: |-
All fields of `user` are required. The whole record will be updated with exactly what you provide here. It is assumed that you already have all information about the user beforehand
@ -209,6 +231,12 @@ paths:
items:
type: string
example: 'userid'
422:
description: Validation error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
delete:
summary: Remove user(s) from trash
tags:
@ -237,6 +265,12 @@ paths:
items:
type: string
example: 'userid'
422:
description: Validation error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
/api/users/private/trash/clean:
delete:
summary: Delete user(s) for good from trash
@ -262,6 +296,12 @@ paths:
type: array
items:
type: string
422:
description: Validation error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
/api/users/private/trash/list:
get:
summary: List users in trash
@ -319,6 +359,14 @@ components:
password:
type: string
example: 'argon2-hash-here'
ValidationError:
type: object
properties:
field_name:
type: array
items:
type: string
example: 'This field is invalid!'
securitySchemes:
session:
type: http