knuckleswtf / knuckleswtf/scribe

I have a request that receives a JSON string that I decode and then validate. I'm getting an exception when trying to generate documentation.

Open
#761 3 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
PHP
Stars
2.3k
Forks
357
PR merge metrics
No merged PRs in 30d

Description

### Scribe version

4.25.0

### Your question

Hi everyone,

My normal routes are working fine except two where I have a nested array of objects which I'm sending through a formdata. In order to be able to access the data before validating it I have to loop through it and decode it. As the title says I'm running into an issue following the below validation method:

```
private function validate(Request $request)
{
$request_data = $request->all();

foreach ($request_data as $key => $value) {
$request_data[$key] = json_decode($value, true);
}
$rules = [
'data' => 'required|array',
'data.*.id' => 'required|numeric',
'data.*.countries' => 'required|array',
'data.*.countries.*' => 'required|numeric',
'data.*.leadTime' => 'required',
'data.*.leadTime.value' => 'required|numeric',
'data.*.leadTime.unit' => 'required|string',
'data.*.quote' => 'required|numeric',
];
$validator = Validator::make($request_data, $rules);
if ($validator->fails()) {
throw ValidationException::withMessages($validator->errors()->toArray());
}
return $request_data;
}

```

Should I handle my validation differently for it to work?

### Docs

- [X] I've checked [the docs](https://scribe.knuckles.wtf/laravel), the [troubleshooting guide](https://scribe.knuckles.wtf/laravel/troubleshooting), and [existing issues](https://github.com/knuckleswtf/scribe/issues?q=is%3Aissue+), but I didn't find a solution

Contributor guide

Open the contributing guide

Research direction

Reproduce the two form-data routes on Scribe 4.25.0 using the provided validate(Request $request) method and nested validation rules. First capture the exact exception produced during documentation generation, then compare the behavior with the Laravel documentation and Scribe troubleshooting guide. Done means the cause and a verified workaround or fix are documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
laravel, php
Domain
api, backend, documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.