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

out of the box error: null returned in ResourceContainer #10

Open
Mina-R-Meshriky opened this issue Aug 9, 2021 · 3 comments
Open

out of the box error: null returned in ResourceContainer #10

Mina-R-Meshriky opened this issue Aug 9, 2021 · 3 comments

Comments

@Mina-R-Meshriky
Copy link

I am trying the package out of the box, couldn't generate the documentation on a running project though

LaravelJsonApi\OpenApiSpec\ResourceContainer::resource(): Return value must be of type LaravelJsonApi\Core\Resources\JsonApiResource, null returned

  at vendor/byteit/openapi-spec-generator/src/ResourceContainer.php:34
     30▕         $fqn = $this->getFQN($model);
     31▕         if(!isset($this->resource[$fqn])){
     32▕             $this->loadResources($fqn);
     33▕         }
  ➜  34▕         return $this->resources[$fqn]->first();
     35▕     }
     36▕ 
     37▕     /**
     38▕      * @param  mixed  $model

      +11 vendor frames 
  12  [internal]:0
      LaravelJsonApi\OpenApiSpec\Builders\PathsBuilder::LaravelJsonApi\OpenApiSpec\Builders\{closure}(Object(LaravelJsonApi\OpenApiSpec\Route))

      +2 vendor frames 
  15  [internal]:0
      LaravelJsonApi\OpenApiSpec\Builders\PathsBuilder::LaravelJsonApi\OpenApiSpec\Builders\{closure}(Object(Illuminate\Support\Collection), "/settings")
@Mina-R-Meshriky Mina-R-Meshriky changed the title out of the box error out of the box error: null returned in ResourceContainer Aug 9, 2021
@captnCC
Copy link

captnCC commented Aug 10, 2021

Is your DB empty? At this point it is a hard requirement, that for each model that has a Schema, sample data must be present.

@Mina-R-Meshriky
Copy link
Author

but why dont we use the model factory for the sample ? instead of the database I mean
or if the database has no data, don't insert a sample

@captnCC
Copy link

captnCC commented Aug 10, 2021

To the first question: The factory would be satisfying for simple schemas. But I think for more complex setups with many models and relations, the usage of a seeded DB is more suitable. This allows the developer to create a complete dataset via Seeder or an imported DB dump.
But yes it is planned to make the sample generation completely optional!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants