Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bodyParameters array example are not being used #909

Open
1 task done
latheesan-k opened this issue Oct 30, 2024 · 1 comment
Open
1 task done

bodyParameters array example are not being used #909

latheesan-k opened this issue Oct 30, 2024 · 1 comment
Labels
awaiting info question Further information is requested

Comments

@latheesan-k
Copy link

Scribe version

4.37.2

Your question

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

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

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 and the suggestions from here didn't help.

Any ideas?

Docs

@latheesan-k latheesan-k added question Further information is requested triage labels Oct 30, 2024
@shalvah
Copy link
Contributor

shalvah commented Nov 5, 2024

Can you remove the 'type' => 'array',?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting info question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants