scribe icon indicating copy to clipboard operation
scribe copied to clipboard

Validation rules forces body or query params?

Open helgur opened this issue 1 year ago • 2 comments

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

helgur avatar Aug 06 '23 16:08 helgur

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.

shalvah avatar Aug 07 '23 12:08 shalvah

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

helgur avatar Aug 07 '23 12:08 helgur