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 of form request validation are not parsed into OpenAPI file #938

Closed
1 task done
AryaSvitkona opened this issue Jan 20, 2025 · 2 comments
Closed
1 task done
Labels
bug Something isn't working

Comments

@AryaSvitkona
Copy link

AryaSvitkona commented Jan 20, 2025

Scribe version

4.39.0

PHP version

8.3.8 (cli)

Framework

Laravel

Framework version

11.34.2

Scribe config

'type' => 'external_static',

    // See https://scribe.knuckles.wtf/laravel/reference/config#theme for supported options
    'theme' => 'elements',

What happened?

We are facing the same issue with the required rule in our form request, which is not parsed correctly and written into out OpenAPI spec. The update to the latest version 4.39.0 did not solve the issue.

Rules

public function rules(): array {
        return [
            'meta.creation-date' => ['required', new Iso8601()],
            'data.*.creation-date' => ['required', new Iso8601()],
        ];
    }

Screenshot:
Screenshot 2025-01-13 at 10 59 59

OpenAPI

      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                meta:
                  type: object
                  description: ''
                  
                  nullable: false
                  properties:
                    creation-date:
                      type: string
                      description: ''
                      example: et
                      nullable: false
                   required: // Line is expected, but missing
                      - creation-date // Line is expected but missing
                data:
                  type: array
                  description: ''
                  example:
                    - []
                  items:
                    type: object
                    properties:
                      creation-date:
                        type: string
                        description: ''
                        example: magni
                        nullable: false
                    required:
                      - creation-date
      security: []

Expected behaviour:
Both properties are marked as required

I tried to understand the logic how a required parameter is extracted, set and written into the OpenAPI spec, but seems to be a little to complex.

Docs

@AryaSvitkona AryaSvitkona added bug Something isn't working triage labels Jan 20, 2025
@shalvah shalvah added enhancement New feature or request bug Something isn't working and removed bug Something isn't working triage enhancement New feature or request labels Feb 3, 2025
@shalvah
Copy link
Contributor

shalvah commented Feb 3, 2025

Fixed in 99b71eb

@shalvah shalvah closed this as completed Feb 3, 2025
@AryaSvitkona
Copy link
Author

@shalvah Thank you very much for your effort! I can confirm, that it works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants