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

Required fields from rules() are not parsed into OpenAPI file #916

Closed
1 task done
torgeros opened this issue Nov 8, 2024 · 1 comment
Closed
1 task done

Required fields from rules() are not parsed into OpenAPI file #916

torgeros opened this issue Nov 8, 2024 · 1 comment
Labels
bug Something isn't working triage

Comments

@torgeros
Copy link

torgeros commented Nov 8, 2024

Scribe version

4.38.0

PHP version

8.3.10 (cli)

Framework

Laravel

Framework version

10.48.20

Scribe config

base_url => "http://localhost:8000"
static.output_path => "scribe_docs"

What happened?

I have rules() that should tag object members as required.

For the generated scribe html file, everything not-required is correctly tagged as optional.
However, the generated openapi.yaml does not set required for all fields that are not optional.

Interestingly, member of objects in objects do not seem to work, while members of objects in arrays do.

Nested Object case (does not work)

This is a section of my rules function:

public function rules(): array
{
    return [
        'whitelabel' => 'string',
        'isPreview' => 'boolean',

        'issuer.email' => 'required|email',
        'issuer.phone' => 'nullable|string'

        // more rules...
    ];
}

This is the generated (& rendered) OpenAPI document:

image

And this is what I would expect (I changed the openapi doc manually):

image

Array of Objects case (does work!)

rules() snippet:

        'items.*.description' => 'string',
        'items.*.quantity' => 'required|numeric',

Generated OpenAPI doc:

image

Docs

@torgeros torgeros added bug Something isn't working triage labels Nov 8, 2024
@shalvah
Copy link
Contributor

shalvah commented Nov 9, 2024

I think that's fixed by #905. I'll try to tag a release soon.

@shalvah shalvah closed this as completed Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

2 participants