knuckleswtf / scribe

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

Validation rules forces body or query params? #702

Open helgur opened 11 months ago

helgur commented 11 months ago

Scribe version

4.22.0

Your question

I've been trying to solve this issue for the better part of the last 3 hours now. As soon as I use validation rules either in a custom request or the controller itself in laravel scribe insists on tacking on the fields as either query parameters or body parameters, even though I am only using url parameters to pass data through the API endpoint

Are there any solutions to this?

Docs

shalvah commented 11 months ago

Hey, sorry for that. This is a known limitation of Scribe. Most validation rules are for request bodies, so we assume that by default. We're still trying to workshop for a solution: https://github.com/knuckleswtf/scribe/issues/692#issuecomment-1615197321 Perhaps maybe we can support a magic comment above the validation rules for this.

helgur commented 11 months ago

That sounds like a good idea. In the meantime I've just used queryParameters() to override any duplicates and just mark them as placeholders and removing their examples. But it's obviously not ideal.

Another alternative is to remove validation alltogether and just code any validation manually in the controller. But it gets messy and introduces potential for a lot of undocumented stuff, the very thing scribe is meant to help alleviate