Skip to content

php artisan openapi:make-schema User -m User generates Error in Laravel > 8 #48

@wedamir

Description

@wedamir

I'm using Laravel 8 and
php artisan openapi:make-schema User -m User command is not working correctly.
because of new namespace for Models App\Models\User

i fixed this in my project by adding 1 line in SchemaFactoryMakeCommad class.

    protected function buildModel($output, $model)
    {
        $model = Str::start($model, $this->laravel->getNamespace());

        if (! is_a($model, Model::class, true)) {
            throw new InvalidArgumentException('Invalid model');
        }
    protected function buildModel($output, $model)
    {
        $namespace = app()::VERSION[0] >= 8 ? $this->laravel->getNamespace(). 'Models\\' : $this->laravel->getNamespace();
        $model = Str::start($model, $namespace);
        
        if (! is_a($model, Model::class, true)) {
            throw new InvalidArgumentException('Invalid model');
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions