L5-Swagger Version: 8.6.0 (composer show | grep l5-swagger)
PHP Version (php -v): 8.3.0
OS: MacOS
Description:
I am trying to attach the Schema from the controller but it doesn't work.
Steps To Reproduce:
Model: Actors.php
/**
* @OA\Schema(
* schema="Actor",
* type="object",
* title="Actor",
* description="Actor Type Model",
* @OA\Property(
* property="id",
* type="integer",
* description="Unique identifier for the actor type"
* ),
* @OA\Property(
* property="name",
* type="string",
* description="Name of the actor type"
* )
* )
*/
class Actor extends Model
{
use HasFactory;
protected $fillable = [
'name',
];
public function organization(): BelongsTo
{
return $this->belongsTo(Organization::class);
}
}
Controller: ActorController.php
/**
* @OA\Get(
* path="/business",
* tags={"Business"},
* summary="Get all Business",
* description="List of all the Business Types",
* operationId="getBusinessTypes",
* @OA\Response(
* response=200,
* description="A list of business types",
* @OA\JsonContent(
* type="array",
* @OA\Items(ref="#/components/schemas/Actor")
* )
* ),
* @OA\Response(
* response=401,
* description="Unauthorized"
* ),
* security={{"bearerAuth":{}}}
* )
*/
public function index()
{
$actors = Actor::all();
return response()->json(ActorTypeResource::collection($actors));
}
When I generate the swagger, I get the following error.
$ref "#/components/schemas/" not found for @OA\Items() in \App\Http\Controllers\ActorController->index()
at vendor/zircote/swagger-php/src/Loggers/DefaultLogger.php:31
27▕ } else {
28▕ $error_level = E_USER_WARNING;
29▕ }
30▕
➜ 31▕ trigger_error($message, $error_level);
32▕ }
33▕ }
34▕
If I replace the @OA\Items(ref="#/components/schemas/Actor") it generates but throws error in the Swagger UI.
Resolver error at paths./actor.get.responses.200.content.application/json.schema.items.$ref
Could not resolve reference: undefined The route components/schemas/Actor could not be found.
composer show | grep l5-swagger
)php -v
): 8.3.0Description:
I am trying to attach the Schema from the controller but it doesn't work.
Steps To Reproduce:
Model: Actors.php
Controller: ActorController.php
When I generate the swagger, I get the following error.
If I replace the
@OA\Items(ref="#/components/schemas/Actor")
it generates but throws error in the Swagger UI.So how to fix this?