Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to document request body params (in validation rules): allow overriding a rule, adding description, and example #73

Closed
romalytvynenko opened this issue Nov 22, 2022 · 2 comments · Fixed by #88
Labels
enhancement New feature or request

Comments

@romalytvynenko
Copy link
Member

romalytvynenko commented Nov 22, 2022

$request->validate([
    /**
     * A foo property.
     *
     * @example 'bar'
     */
    'foo' => 'string',
]);

Or simply like so without an example:

$request->validate([
    /** A foo property. */
    'foo' => 'string',
]);

Users should be able to override the type as well:

$request->validate([
    /**
     * @var array{bar: string}
     */
    'foo' => 'array',
]);

Questions

What about comments support?

Seems like this needs to be supported too, because of responses documenting.

$request->validate([
    // A foo property.
    'foo' => 'string',
]);
@romalytvynenko romalytvynenko added the enhancement New feature or request label Nov 22, 2022
@soilSpoon
Copy link

I think it would be nice to use FormRequest's attributes method.

@romalytvynenko romalytvynenko changed the title Add ability to document request body params (in validation rules): allow adding description and example Add ability to document request body params (in validation rules): allow overriding a rule, adding description, and example Nov 30, 2022
@romalytvynenko
Copy link
Member Author

@soilSpoon that would be fun for sure!

Do you have some examples from your real codebase you can share?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants