knuckleswtf / scribe

Generate API documentation for humans from your Laravel codebase.✍
https://scribe.knuckles.wtf/laravel/
MIT License
1.7k stars 303 forks source link

Example request not adhering to FormRequest Rules #799

Open YentlHendrickx opened 7 months ago

YentlHendrickx commented 7 months ago

Scribe version

4.29.0

PHP version

8.2.15

Framework

Laravel

Framework version

v9.52.6

Scribe config

title => "Kuubix Configbox API"
base_url => "http://127.0.0.1:8000"
try_it_out.enabled => false
auth.enabled => true
auth.in => "header"
auth.name => "x-api-key"
strategies.urlParameters => added Knuckles\Scribe\Extracting\Strategies\UrlParameters\GetFromLumenAPI
strategies.headers => added Knuckles\Scribe\Extracting\Strategies\Headers\GetFromRouteRules: removed [
    'override',
    [
        'Content-Type' => 'application/json',
        'Accept' => 'application/json',
    ],
]
strategies.responses => added Knuckles\Scribe\Extracting\Strategies\Responses\ResponseCalls: removed [
    'Knuckles\\Scribe\\Extracting\\Strategies\\Responses\\ResponseCalls',
    [
        'only' => [
            'GET *',
        ],
    ],
]

What happened?

First off thank you for this package, apart from this bug it's been working flawlessly!

So I have generated my docs and everything seemed to be fine. However it appears that scribe is not adhering to the validation rules when generating the example request?

This is part of our FormRequest, which as you can see has different validation rules applied. image

After generating the docs, and looking at the request this is what I see: image

So the example request does include the 'articles' but it does not include every single required field. When looking at the actual specification besides it: image

You can see that in this case scribe does seem to recognize that 'name' and 'price_excl' are required fields, but this is not reflected in the generated example.

I do know I could just give my own example and that would solve this. But it does appears that this is a bug? Unless I'm doing something wrong on my side.

Again thank you for all the work on this, it makes our lives a lot easier!

Docs

shalvah commented 7 months ago

Interesting, it does seem like a bug. What happens when you remove the .OBX fields from your validation rules?

YentlHendrickx commented 7 months ago

Hi thank you for the quick reply!

So I removed the .OBX validation rules and now the articles are not present in the example at all. image

I have also tried making the articles 'required' like so: image But that doesn't seem to change the behavior.