Laravel Scribe документирует пример массива внутри bodyParameters в FormRequestPhp

Кемеровские программисты php общаются здесь
Ответить
Anonymous
 Laravel Scribe документирует пример массива внутри bodyParameters в FormRequest

Сообщение Anonymous »

Я документирую свой API Laravel с помощью Scribe
Один из моих API использует FormRequest, который выглядит следующим образом:

Код: Выделить всё

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],
],
];
}
}
При создании документации API описание и пример из bodyParameters не используются, а вместо этого генерируется следующее:< /p>
Изображение
Я пробовал разные методы, но ни один из них не работает, есть идеи?

Подробнее здесь: https://stackoverflow.com/questions/791 ... ormrequest
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Php»