knuckleswtf / scribe

Generate API documentation for humans from your Laravel codebase.✍
https://scribe.knuckles.wtf/laravel/
MIT License
1.58k stars 280 forks source link

suppressing FormRequest attributes added in prepareForValidation #802

Open ceejayoz opened 4 months ago

ceejayoz commented 4 months ago

Scribe version

4.29.0

Your question

We have an API endpoint with a FormRequest that takes a filename as input.

In prepareForValidation(), we do $this->merge(['extension' => pathinfo($this->input('filename'), PATHINFO_EXTENSION)]); to determine the file extension. We then validate the resulting extension value in the rules() function.

In the resulting documentation, the extension parameter shows up, which makes readers think it can/should be sent instead of being computed for validation purposes as it actually is. Is there a way to suppress this attribute from the resulting documentation?

Docs

shalvah commented 4 months ago

Scribe has a lot of functionality, so there's almost certainly a way to do what you want. 😅 most straightforward way I can think of right now is adding a custom strategy that runs after the validation rules strategies. They're meant for adding information, but nothing stops you from removing as well.

Alternative option would be to override the validation rules strategies with yours, but that might be trickier.