❓Define a request
So start writing your own FormRequest (php artisan make:request ExampleRequest) and type-hint it on the method signature.
The only change you need to do in your existent request is to apply the #[OpenApi\Request] attribute.
use Hypnodev\OpenapiGenerator\Attributes\OpenApi;
#[OpenApi\Request(description: 'An example description of the request')]
class ExampleRequest extends FormRequest
{
// ...
}
Be aware that attribute isn't supporting (yet) the notation.
Package will bring all the rules inside the requests and make the right definition.
Example
// ...
public function rules(): array
{
return [
'name' => ['required', 'string'],
'email' => ['required', 'email'],
'id' => ['required', 'uuid'],
'url' => ['required', 'url'],
'date' => ['required', 'date_format:Y-m-d', 'date'],
'status' => ['bool'],
'enum_as_string' => ['in:test'],
'enum_as_closure' => [Rule::in(['test', ExampleEnum::Status1])],
'array' => ['array'],
'array.*' => ['string'],
'object' => ['array'],
'object.name' => ['string'],
];
}

Last updated