knuckleswtf / knuckleswtf/scribe
Inline validating body and query parameters simultaneously
- Dominant language
- PHP
- Stars
- 2.3k
- Forks
- 357
- PR merge metrics
- No merged PRs in 30d
Description
I am using inline validation to validate both body and query parameters in a POST endpoint. It looks something like this:
```
$request->validate([
'limit' => 'required|numeric|min:0',
'nextPeriod' => 'required|boolean',
]);
```
limit is a body parameter and nextPeriod is a query parameter. By default, Scribe interprets both as body parameters. I know I can add a "// Query parameters" comment above $request->validate() but then both will be interpreted as query parameters. If I add @queryParam and @bodyParam comments above the controller method Scribe will read both the comments and the request validation resulting in the query parameter appearing both in query and body parameters.
Is there a way to comment what parameters are query/body inside the inline validation? Something like:
```
$request->validate([
// @bodyParam
'limit' => 'required|numeric|min:0',
// @queryParam
'nextPeriod' => 'required|boolean',
]);
```
Or any other way to separate query and body parameters when validating both, without getting duplicates?
Contributor guide
Research direction
Start by reviewing how Scribe handles inline $request->validate() calls and how @queryParam and @bodyParam annotations are parsed. The change is complete when a single validation containing both kinds of parameters assigns each parameter to the correct location without duplicates; the issue names no specific files or tests to run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- laravel, php
- Domain
- api, documentation
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100