Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

generated base controller wrong namespace in findModel #147

Open
@daronjay

Description

@daronjay

Hi, I have looked online and in the docs, cant see this issue. When I generate with ./yii gii/api --openApiPath=http://localhost:3000/documentation/json

My base classes all have a broken findModel method. I am getting

public function findModel($id)
{
        $model =  \::findOne($id); 
        
        if ($model !== null) {   
        
            return $model;  
            
        }       
        
        throw new \yii\web\NotFoundHttpException("Object not found: $id");      
  }

where I would be expecting say \common\models\Company::findOne($id).

I assume some config isn't set right, but I'm blowed if i can see how.

Activity

SOHELAHMED7

SOHELAHMED7 commented on Jun 1, 2023

@SOHELAHMED7
Contributor

Have you configured ApiGenerator like mentioned in https://github.com/cebe/yii2-openapi#usage

daronjay

daronjay commented on Jun 1, 2023

@daronjay
Author

So I have:

generators =>   [
      'api' => [
        'class' => \cebe\yii2openapi\generator\ApiGenerator::class,
        'urlConfigFile' => '@api/config/url-rules.rest.php',
        'controllerNamespace' => 'api\\controllers',
        'modelNamespace' => 'common\\models',
        'fakerNamespace' => 'common\\models\\faker',
        'migrationPath' => '@common/migrations',
    ]
  ],

We are running php 8.2.3, wondering if its some incompatibility?

SOHELAHMED7

SOHELAHMED7 commented on Jun 2, 2023

@SOHELAHMED7
Contributor

We are running php 8.2.3, wondering if its some incompatibility?

Yes it is incompatible. But the PR for PHP 8.2 compatibility is completed and tests are passing and new version of this lib is not released yet.

Steps to run that version of this lib in your project using PHP 8.2.* can be found at https://github.com/SOHELAHMED7/yii2-openapi/blob/master/CONTRIBUTING.md#use-pr-of-your-own-fork-of-this-library-in-your-project-to-check-new-changes

Feel free to write us back with your experience and whether your issue is fixed.

SOHELAHMED7

SOHELAHMED7 commented on May 30, 2024

@SOHELAHMED7
Contributor

This issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @daronjay@SOHELAHMED7

        Issue actions

          generated base controller wrong namespace in findModel · Issue #147 · cebe/yii2-openapi