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

@ -18,19 +18,16 @@ paths:
schema: schema:
type: object type: object
properties: properties:
user: last_name:
type: object type: string
properties: name:
last_name: type: string
type: string middle_name:
name: type: string
type: string email:
middle_name: type: string
type: string phone:
email: type: string
type: string
phone:
type: string
password: password:
type: string type: string
example: 'strong_password123' example: 'strong_password123'
@ -56,6 +53,12 @@ paths:
schema: schema:
type: string type: string
example: 'bad_password' example: 'bad_password'
422:
description: Validation error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
/api/users/login: /api/users/login:
post: post:
tags: tags:
@ -86,10 +89,13 @@ paths:
| key | val | | 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 | | `bad_password` | authentication unsuccessful; this means that there is either no user with this email, or password doesn't match |
422:
This error also might be sent by laravel if your body is corrupted description: Validation error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
/api/users/reset: /api/users/reset:
post: post:
tags: tags:
@ -112,6 +118,12 @@ paths:
200: 200:
description: |- description: |-
The password is reset The password is reset
422:
description: Validation error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
/api/users/private/list: /api/users/private/list:
get: get:
@ -147,8 +159,12 @@ paths:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/User' $ref: '#/components/schemas/User'
400: 422:
description: Invalid ID description: Validation error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
404: 404:
description: User not found description: User not found
/api/users/private/edit/{id}: /api/users/private/edit/{id}:
@ -166,6 +182,12 @@ paths:
responses: responses:
200: 200:
description: OK description: OK
422:
description: Validation error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
requestBody: requestBody:
description: |- 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 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: items:
type: string type: string
example: 'userid' example: 'userid'
422:
description: Validation error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
delete: delete:
summary: Remove user(s) from trash summary: Remove user(s) from trash
tags: tags:
@ -237,6 +265,12 @@ paths:
items: items:
type: string type: string
example: 'userid' example: 'userid'
422:
description: Validation error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
/api/users/private/trash/clean: /api/users/private/trash/clean:
delete: delete:
summary: Delete user(s) for good from trash summary: Delete user(s) for good from trash
@ -262,6 +296,12 @@ paths:
type: array type: array
items: items:
type: string type: string
422:
description: Validation error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
/api/users/private/trash/list: /api/users/private/trash/list:
get: get:
summary: List users in trash summary: List users in trash
@ -319,6 +359,14 @@ components:
password: password:
type: string type: string
example: 'argon2-hash-here' example: 'argon2-hash-here'
ValidationError:
type: object
properties:
field_name:
type: array
items:
type: string
example: 'This field is invalid!'
securitySchemes: securitySchemes:
session: session:
type: http type: http