knuckleswtf / scribe

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

Automatic generate example #776

Closed majuca closed 5 months ago

majuca commented 6 months ago

Scribe version

4.26.0

Your question

Hi,

Could be possible to add a option in the config to prevent automatic generation of examples? I tried to have an empty array for models_source but scribe create example with null value.

'examples' => [
        /*
         * If you would like the package to generate the same example values for parameters on each run,
         * set this to any number (eg. 1234)
         */
        'faker_seed' => null,

        /*
         * With API resources and transformers, Scribe tries to generate example models to use in your API responses.
         * By default, Scribe will try the model's factory, and if that fails, try fetching the first from the database.
         * You can reorder or remove strategies here.
         */
        'models_source' => [],
    ],

Docs

shalvah commented 5 months ago

That's disabling a whole feature. So what you mean is you don't want the code samples in the docs, or parameter examples in the OpenAPI spec?

majuca commented 5 months ago

If y remove the factories in models_source, when I generate the api documentation, I still have exemple with empty values, like this:

image

My point of view, if the models_source is empty, the response example should not be generated.

I would like to manage my response only with a @responseFile

majuca commented 5 months ago

ok, the happens if you mixed @apiResource and @responseFile. If y remove @apiResource it works as expected.