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

Undefined property: Knuckles\Camel\Extraction\ResponseField::$example #578

Closed
Peterragheb opened this issue Dec 5, 2022 · 0 comments
Closed
Labels
bug Something isn't working

Comments

@Peterragheb
Copy link
Contributor

What happened?

  1. I ran php artisan scribe:generate --verbose
  2. And I got:
 Undefined property: Knuckles\Camel\Extraction\ResponseField::$example

Screenshots and stack traces:

 Undefined property: Knuckles\Camel\Extraction\ResponseField::$example

  at vendor/knuckleswtf/scribe/src/Extracting/Extractor.php:437
    433▕                         "name" => $parentName,
    434▕                         "type" => $parentName === '[]' ? "object[]" : "object",
    435▕                         "description" => "",
    436▕                         "required" => true,
  ➜ 437▕                         "example" => [$fieldName => $parameter->example],
    438▕                     ]);
    439▕                 }
    440▕             }
    441▕             $normalisedParameters[$name] = $parameter;

  1   vendor/knuckleswtf/scribe/src/Extracting/Extractor.php:437
      Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap\{closure}("Undefined property: Knuckles\Camel\Extraction\ResponseField::$example", "/Users/peterragheb/Developer/Laravel/project/vendor/knuckleswtf/scribe/src/Extracting/Extractor.php")

  2   vendor/knuckleswtf/scribe/camel/Output/OutputEndpointData.php:109
      Knuckles\Scribe\Extracting\Extractor::nestArrayAndObjectFields()

  3   vendor/knuckleswtf/scribe/camel/BaseDTO.php:29
      Knuckles\Camel\Output\OutputEndpointData::__construct()

  4   vendor/knuckleswtf/scribe/src/GroupedEndpoints/GroupedEndpointsFromApp.php:180
      Knuckles\Camel\BaseDTO::create()

  5   vendor/knuckleswtf/scribe/src/GroupedEndpoints/GroupedEndpointsFromApp.php:124
      Knuckles\Scribe\GroupedEndpoints\GroupedEndpointsFromApp::mergeAnyEndpointDataUpdates(Object(Knuckles\Camel\Extraction\ExtractedEndpointData))

  6   vendor/knuckleswtf/scribe/src/GroupedEndpoints/GroupedEndpointsFromApp.php:69
      Knuckles\Scribe\GroupedEndpoints\GroupedEndpointsFromApp::extractEndpointsInfoFromLaravelApp()

  7   vendor/knuckleswtf/scribe/src/GroupedEndpoints/GroupedEndpointsFromApp.php:47
      Knuckles\Scribe\GroupedEndpoints\GroupedEndpointsFromApp::extractEndpointsInfoAndWriteToDisk(Object(Knuckles\Scribe\Matching\RouteMatcher))

  8   vendor/knuckleswtf/scribe/src/Commands/GenerateDocumentation.php:53
      Knuckles\Scribe\GroupedEndpoints\GroupedEndpointsFromApp::get()

  9   app/Console/Commands/GenerateDocumentation.php:32
      Knuckles\Scribe\Commands\GenerateDocumentation::handle(Object(Knuckles\Scribe\Matching\RouteMatcher), Object(Knuckles\Scribe\GroupedEndpoints\GroupedEndpointsFactory))

  10  vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
      App\Console\Commands\GenerateDocumentation::handle(Object(Knuckles\Scribe\Matching\RouteMatcher), Object(Knuckles\Scribe\GroupedEndpoints\GroupedEndpointsFactory))

  11  vendor/laravel/framework/src/Illuminate/Container/Util.php:41
      Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()

  12  vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93
      Illuminate\Container\Util::unwrapIfClosure(Object(Closure))

  13  vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37
      Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Object(Closure))

  14  vendor/laravel/framework/src/Illuminate/Container/Container.php:651
      Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), [])

  15  vendor/laravel/framework/src/Illuminate/Console/Command.php:178
      Illuminate\Container\Container::call()

  16  vendor/symfony/console/Command/Command.php:308
      Illuminate\Console\Command::execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))

  17  vendor/laravel/framework/src/Illuminate/Console/Command.php:148
      Symfony\Component\Console\Command\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))

  18  vendor/symfony/console/Application.php:1014
      Illuminate\Console\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  19  vendor/symfony/console/Application.php:301
      Symfony\Component\Console\Application::doRunCommand(Object(App\Console\Commands\GenerateDocumentation), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  20  vendor/symfony/console/Application.php:171
      Symfony\Component\Console\Application::doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  21  vendor/laravel/framework/src/Illuminate/Console/Application.php:102
      Symfony\Component\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  22  vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:155
      Illuminate\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

  23  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

My environment:

  • PHP version (from php -v): 8.1.8
  • Framework (Laravel/Lumen): Laravel
  • Laravel/Lumen version (from composer show laravel/framework or composer show laravel/lumen-framework): v9.40.1
  • Scribe version (from composer show knuckleswtf/scribe): 4.8.0

My Scribe config (from php artisan scribe:config:diff):

type => "laravel"
auth.name => "Authorization"
strategies.metadata => removed Knuckles\Scribe\Extracting\Strategies\Metadata\GetFromMetadataAttributes
strategies.urlParameters => removed Knuckles\Scribe\Extracting\Strategies\UrlParameters\GetFromUrlParamAttribute
strategies.queryParameters => removed Knuckles\Scribe\Extracting\Strategies\QueryParameters\GetFromQueryParamAttribute
strategies.headers => removed Knuckles\Scribe\Extracting\Strategies\Headers\GetFromHeaderAttribute
strategies.bodyParameters => removed Knuckles\Scribe\Extracting\Strategies\BodyParameters\GetFromBodyParamAttribute
strategies.responses => removed Knuckles\Scribe\Extracting\Strategies\Responses\UseResponseAttributes
strategies.responseFields => removed Knuckles\Scribe\Extracting\Strategies\ResponseFields\GetFromResponseFieldAttribute

Additional info:
I haven't tried to debug the root issue.

But I'm using in some of my controllers (nested responseField):

@responseField object.type string type of object

And since inside Exctractor::nestArrayAndObjectFields it splits on the dot. I replaced it with ->:

@responseField object->type string type of object

It works.

@Peterragheb Peterragheb added the bug Something isn't working label Dec 5, 2022
@shalvah shalvah closed this as completed in 42df1b1 Dec 5, 2022
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

1 participant