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

Hide list of enums from Rules::in validation (BodyParameters) #940

Open
1 task done
gsusanj opened this issue Jan 31, 2025 · 1 comment
Open
1 task done

Hide list of enums from Rules::in validation (BodyParameters) #940

gsusanj opened this issue Jan 31, 2025 · 1 comment

Comments

@gsusanj
Copy link

gsusanj commented Jan 31, 2025

Scribe version

4.39.0

Your question

I have a very long list (hundreds) of items in Rule::in().
I would like to hide the "Must be one of" in the generated docs, but I can not find a way to do this.
Did I miss anything?

Using the FormRequest variant:

<?php
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, mixed>
     */
    public function rules(): array
    {
        return [
            'records.*.data.*.descriptor' => [ 'required', 'string', Rule::in( Descriptor::getAllUids() ) ],
        ];
    }
    /**
     * Documentation for Scribe API documentary.
     *
     * @return array[]
     */
    public function bodyParameters(): array
    {
        return [
            'records.*.data.*.descriptor' => [
                'description' => 'UID of the descriptor.',
                'example'     => '0.0.NTSCD55',
            ],
        ];
    }

Image

Docs

@shalvah
Copy link
Contributor

shalvah commented Feb 3, 2025

Hmm, you could disable the FormRequest strategy, or replace it with a custom strategy that ignores the rule.

Alternatively, we can add a check to not include this description if the items are above a certain count, but there are some considerations:

  • How many is "too many"? 10? 20? It's quite arbitrary.
  • What about OpenAPI spec and Postman collection? Do we show all there?

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants