Idea, somehow get data required and optional from FormRequest
AucT opened this issue ยท 18 comments
I think would be noice to have autofetching data from rules in FromRequest and add this inputs to postman.
one more thing. I think it is better to make this tool external.
Something like binary u download and run.
Or at least require dev
@andreaselia is right, it would be a very heavy lift in order to "fake" the data properly. I've had this thought for v2 and I keep going in circles about how to hand it. The simplest way I can think of would be to map the type of attribute to the equivalent in faker, i.e. 'name' => 'string'
would be faker()->string()
.
There aren't any plans currently to make this an executable.
Hi Team, when I enable_formdata postman API rejects my collection "name":"malformedRequestError","message":"Found 241 errors with the supplied collection."
@kodunmi could you post the collection here please? Feel free to remove any sensitive data.
Okay bro @andreaselia
I have been trying all I can be it wouldn't just work, any help would be greatly appreciated.
spv2devapi.json
I can import it directly, but it doesn't allow me, when I try creating collection via API
Have you tried commenting out all of the routes apart from one, and generating it to see if it works?
Re-enable routes one by one to find the problematic one perhaps?
Okay, I will try that today and get back to you.
Hi @andreaselia thanks for your help
I just left only the login route and I still got errors
Route::prefix('users')->group(function () {
Route::prefix('auth')->group(function () {
Route::post('login', LoginController::class);
});
});
My request rules
public function rules(): array
{
return [
'phone' => ['required', 'string'],
'phone_code' => ['required_with:phone', 'string', Rule::exists('countries', 'phone_code')],
'password' => ['required', 'string'],
];
}
Response Data: {"error":{"name":"malformedRequestError","message":"Found 8 errors with the supplied collection.","details":["item/0/request/body/urlencoded/0/value: must be string","item/0/request/body/urlencoded/1/value: must be string","item/0/request/body: must be null","item/0/request/body: must match exactly one schema in oneOf","item/0/request: must be string","item/0/request: must match exactly one schema in oneOf","item/0: must have required property 'item'","item/0: must match exactly one schema in oneOf"]}}
My setting
'structured' => true,
'enable_formdata' => true,
Thanks for the information. One thing I can see is there's no name on your route.
// without name
Route::post('login', LoginController::class);
// with name
Route::post('login', LoginController::class)->name('login');
Okay @andreaselia, let's try to add a name and see.
Hi, @andreaselia I love this package too much to give up.
I have added a name to the login route, but it still 400
Route::post('login', LoginController::class)->name('login');
The package works just fine if I don't enable enable_formdata, but immediately after I set it to try, we start having issues
@kodunmi thank you for your package love! I will certainly try to resolve this issue with you.
Do you have time to try to reproduce this issue with a test case in the package (if you know how to do that)? It would help us greatly in trying to reproduce the issue.
Okay, I will try to do that today, so I should do the following
- Create a fresh laravel project
- Install package
- Add some route
- Enable form_data
- Add actions to push collection to postman using api
- Add you to the repo
Would this be okay? @andreaselia
That would be great @kodunmi, thank you very much ๐
Going to close this for now. If you're able to reproduce this in a fresh repo that we could try it out in that would be great @kodunmi. I'll re-open this if an issue is found in said replication repo.