ScienceForChange / SoundCollect_backend

0 stars 0 forks source link

API documentation #26

Closed OtariOboladzeSfC closed 3 months ago

OtariOboladzeSfC commented 5 months ago

https://github.com/ScienceForChange/soundCollect/blob/94477988b4621c5b65bcfe4450a505aee1da8c7c/api/app/Http/Controllers/Auth/LoginController.php#L44

the API documentation refers to 422 and 500 errors besides 200, when are the 422 and 500 created? better said: how to manually invoke them? 422 and 500 are not defined in the code right? are they created automatically by Laravel when exception occurs?

OtariOboladzeSfC commented 5 months ago

I have also added same comment directly within the API documentation page

CarlosMillanSfC commented 5 months ago

@OtariOboladzeSfC

the API documentation refers to 422 and 500 errors besides 200, when are the 422 and 500 created?

When a validation class or method fails it throws a ValidationException which a 422 code status. And 500 are the same, when something fails at server level it responds with a 5xx response according at the problem, automatically most of the times

better said: how to manually invoke them? 422 and 500 are not defined in the code right? are they created automatically by Laravel when exception occurs?

To manually invoke then you can do it as you please, normally i use the trait ApiResponses and as you see there is a fail method (like something wrong but "not critical" i would say) and error (more likely critical). To the last two question iwould say yes, they are not defined in the code and created automatically by laravel most of the times but as i said, you can use the APIResponses trait.