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

Extended Request Class Not Showing Description or Default Value in Auto-Generated API Documentation #634

Open
michaelpoernomo opened this issue Nov 22, 2024 · 0 comments

Comments

@michaelpoernomo
Copy link

Description

When using an extended request class in Laravel, the description in the extended class and default values defined in the base class do not appear in the auto-generated API docs.

Problem:

class GetRequest extends BaseRequest
{
    public function rules(): array
    {
        return [
            /**
             * @default 1
             */
            'page' => 'required|integer',
            /**
             * @default 100
             */
            'per_page' => 'required|integer',
            'keyword' => 'sometimes|string|max:255',
            'sort_column' => 'sometimes|string',
            'sort_direction' => 'sometimes|string|in:asc,desc'
        ];
    }
}
class GetRequestByClient extends GetRequest
{
    public function rules(): array
    {
        $rules = parent::rules();
        /**
         * Conditionally add the 'client_id' rule
         */
        $rules['client_id'] = Auth::user() ? 'sometimes|string' : 'prohibited';
        return $rules;
    }
}

result:
Screenshot 2024-11-22 at 10 59 48

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

No branches or pull requests

1 participant