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

Config routes.apply.response_calls does not work after upgrading to latest #828

Closed Grldk closed 3 months ago

Grldk commented 3 months ago

Scribe version

4.31.0

PHP version

8.1.27

Framework

Laravel

Framework version

10.45.1

Scribe config

<?php

use Knuckles\Scribe\Extracting\Strategies;

return [
    'routes' => [
        [
            'apply' => [
                'headers' => [
                    'Content-Type' => 'application/json',
                    'Accept' => 'application/json',
                ],
                'response_calls' => [
                    'methods' => ['GET', 'POST'],
                    'config' => [
                        'app.env' => 'testing',
                        'app.debug' => false,
                    ],
                    'queryParams' => [],
                    'bodyParams' => [],
                    'fileParams' => [],
                    'cookies' => [],
                ],
            ],
        ],
    ],
];

What happened?

I'm in the process of upgrade scribe from 4.23.1 to 4.31.0. This upgrade broke my doc generation. It seems that the settings from the response_calls array are not set when making Response Calls anymore. I specifically noticed this because I set app.debug to false in the scribe config, but the generated docs contain error responses with full traces, which are only added when app.debug is true. In 4.23.1 setting debug to false this way worked fine.

I'm guessing this is an unnoticed breaking change of 4.28?

Docs

shalvah commented 3 months ago

That's probably https://github.com/knuckleswtf/scribe/pull/816. A new way to configure response calls was introduced, but I inadvertently broke the old one. It was fixed in 4.33.0.

Btw, I recommend switching to the new syntax. Only takes a moment to switch over. image (docs)

In your case, this should look like:

'strategies' => [
// ...
'responses' => [
  Strategies\Responses\UseResponseAttributes::class,
  // other strategies...
  [
    Strategies\Responses\ResponseCalls::class,
    [
      'only' => ['GET *', 'POST *'],
      'config' => [
        'app.env' => 'testing',
        'app.debug' => false,
      ],
    ],
  ]
],