knuckleswtf / scribe

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

Problem with generating sample when using file type in nested arrays in validation rules #308

Open MohammadMirsafaei opened 3 years ago

MohammadMirsafaei commented 3 years ago

What happened?

  1. I set my configuration to default Scribe config.
  2. Then I ran php artisan scribe:generate
  3. But I saw that for my endpoint it couldn't generate example body request in javascript. it show only: let body =

instead of

cosnt body = new FormData();
body.append....

Screenshots and stack traces:

My environment:

My Scribe config (minus the comments): It's Scribe default config Additional info: My validation rules:

'data' => 'filled|array',
            'data.*' => 'required|array',
            'data.*.is_file' => 'required|boolean',
            'data.*.value' => 'filled|string|required_without:data.*.file',
            'data.*.file' => 'filled|required_without:data.*.value|file|mimes:png,jpg,gif,mp4,mp3|mimetypes:image/jpeg,image/png,video/mp4,audio/mpeg',

I think the problem is when using 2 nested array and the type is file. If I remove data.*.file it works ok.

shalvah commented 3 years ago

Hmm, strange. Do examples in other languages show up?

MohammadMirsafaei commented 3 years ago

sorry for late answering, this bug happens in other languages too

wyfiwyfi commented 3 years ago

Thank you for your help with this. Very much appreciated.