Laravel-apidoc-generator: use validate method to display a list of valid parameters instead Formrequest

Created on 30 Nov 2017  路  10Comments  路  Source: mpociot/laravel-apidoc-generator

From https://github.com/mpociot/laravel-apidoc-generator#form-request-validation-rules , seems that it's required to write FormRequest to create list of valid parameters.

But there is situation that we do not use FormRequest and prefer to use other validation methods like $request->validate :

public function store(Request $request)
{
    $validatedData = $request->validate([
        'title' => 'required|unique:posts|max:255',
        'body' => 'required',
    ]);

    // The blog post is valid...
}

how can I generate valid parameters of methods in this case ?

enhancement help wanted

Most helpful comment

This would be very useful as bigger projects with more specific rules would benefit from this.

All 10 comments

This would be very useful as bigger projects with more specific rules would benefit from this.

I agree, many projects don't make use of FormRequests so this would be a useful feature.

Hey guys. I'm currently working on a fork, which is gonna be fully rewritten. I would be very grateful if you helped me and told what could be the benefit of using $request->validate over FormRequest classes.

I think a lot of comes down to personal preference. If I'm using a form which is going to have common fields I would probably use a FormRequest class. However if I'm working with a lot of specific forms I would probably just write the validation rules in the method or construct. With this in mind, I'd find it very useful having this feature. If there is anything I can do to help to contribute to this project I'd be more than happy to.

@mark1282 Any ideas on how to parse authorize(), custom rules and maybe even responses?

Sure enough we're speaking about parsing the code which is quite difficult. On the other hand, with that method if app is built correctly then generator will be able to parse everything on it's own, which is amazing and more than enough for internal APIs.

Take a look at my fork, I have implemented this feature
https://github.com/oxycoder/laravel-apidoc-generator
This repo seem abadoned

@oxycoder I really like what you did in your fork. I'm using the feature where you parse $request->validator() Could you please turn on issues in your repo? I would like to comment.

@edgreenberg sure

Hey everyone. This feature is in high demand, and we're open to adding it. It's on the map, but we'll accept any PRs to fast-track it.

No longer valid because of #343

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hackel picture hackel  路  8Comments

dozieogbo picture dozieogbo  路  4Comments

shalvah picture shalvah  路  5Comments

chinloyal picture chinloyal  路  8Comments

Herchelle picture Herchelle  路  8Comments