knuckleswtf / knuckleswtf/scribe

bodyParameters array example are not being used

Open
#909 4 comments 0 reactions 0 assignees View on GitHub
awaiting requester action question triage
Dominant language
PHP
Stars
2.3k
Forks
357
PR merge metrics
No merged PRs in 30d

Description

### Scribe version

4.37.2

### Your question

One of my endpoint uses a `FormRequest` which is defined like this:

```php
class StoreInvoiceRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return match($this->method()) {
// Anyone can create new record
'POST' => true,
// Updating must match record owner
'PUT', 'PATCH' => $this->invoice->user_id === auth()->id(),
// Unauthorized for everything else
default => false,
};
}

/**
* Get the validation rules that apply to the request.
*/
public function rules(): array
{
return [
'customer_id' => ['required', Rule::exists('customers', 'id')->where(static function ($query) {
return $query->where('user_id', auth()->id());
})],
'customer_email_ids' => ['present', 'array'],
'customer_email_ids.*' => ['required', 'integer', Rule::exists('emails', 'id')->where(function ($query) {
return $query->where('customer_id', $this->input('customer_id'));
})],
];
}

public function bodyParameters(): array
{
return [
'customer_id' => [
'example' => 1,
],
'customer_email_ids' => [
'description' => 'Array of email IDs associated with the customer (who will receive email notifications)',
'type' => 'array',
'example' => [1, 2, 3],
],
];
}
}
```

The generated api documentation example looks like this:
![image](https://github.com/user-attachments/assets/32eb911f-50e2-49ef-8978-61d49414fe4b)

Scribe is not using the `description` or `example` of the `customer_email_ids` from `bodyParameters`

I have tried various methods and nothing appears to be working. I saw a related question on this from [here](https://github.com/knuckleswtf/scribe/issues/117) and the suggestions from here didn't help.

Any ideas?

### 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 issue 909 using the shown FormRequest and compare the generated API documentation with the bodyParameters description and example. Start by reviewing the Laravel bodyParameters documentation and troubleshooting guide; done means the generated customer_email_ids field uses the declared description and example.

Written by the indexing model from the issue text.

Assessment

Tech stack
laravel, php
Domain
documentation
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.