knuckleswtf / scribe

Generate API documentation for humans from your Laravel codebase.✍
https://scribe.knuckles.wtf/laravel/
MIT License
1.7k stars 303 forks source link

Use Laravel's validation functionality to map body parameters #698

Open TeamNovatag opened 1 year ago

TeamNovatag commented 1 year ago

Scribe version

4.22

PHP version

8.1

Framework

Laravel

Framework version

10.10

Scribe config

try_it_out.enabled => false
auth.enabled => true
auth.default => true
auth.name => "Authorization"
postman.enabled => false
openapi.enabled => false

What happened?

Mapping of validation rules don't work if I use $request->validate in try/catch block. The problem in RequestValidate.php this line: if (!($node instanceof Node\Stmt\Expression)) return;

Node return => RulesPhpParser\Node\Stmt\TryCatch instead RulesPhpParser\Node\Stmt\Expression and exit from mapping

Docs

shalvah commented 1 year ago

Can you provide an example of the code snippet?