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 · 2 comments
Open
1 task done

bodyParameters array example are not being used #909

latheesan-k opened this issue Oct 30, 2024 · 2 comments

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

@shalvah
Copy link
Contributor

shalvah commented Nov 5, 2024

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

@nadlambino
Copy link

Any updates on this? I'm having this issue as well. I am using v4.38. I am also trying to override some of the auto-generated bodyParams, but it does not work as expected. The weird thing is, some of the bodyParams were overriden while others were not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants