Reputation: 97
I have a controller ServiceBookingController
which is outside of laravel traditional app
directory. I am making swagger documentation. It works fine with the controllers which are inside App\Http\Controllers
directory. Here is my controller file
<?php
namespace Modules\Beauty\Http\Controllers\API;// here is the directory
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ServiceBookingController extends Controller{
/**
* @OA\Post(
* path="/beauty/list-customer-service-bookings",
* tags={"beauty_customer_bookings"},
* summary="List Customer Bookings.",
* operationId="Beauty_Customer_Bookings",
* @OA\Parameter(
* name="customer_id",
* in="query",
* description="customer id",
* required=true,
* @OA\Schema(
* type="integer",
* default="482"
* )
* ),
* @OA\Response(
* response=422,
* description="validation errors."
* ),
* @OA\Response(
* response="200",
* description="Customer Bookings."
* ),
* @OA\Response(
* response="401",
* description="auth failed."
* ),
* )
*/
public function list_customer_service_bookings(Request $request)
{
...
}
}
I want to use the swagger inside list_customer_service_bookings
controller for its function list_customer_service_bookings
. The api request isn't rendering in the swagger ui. Any suggestions?
Upvotes: 1
Views: 4494
Reputation: 302
If you are using darkaonline/l5-swagger, run this command:
php artisan vendor:publish --provider "L5Swagger\L5SwaggerServiceProvider"
Now, you can open config/l5-swagger.php : Add your custom directory in annotations. Like this:
'annotations' => [
base_path('app'), // This is default
base_path('modules') // Add your directory
],
I hope it was useful.
Upvotes: 3
Reputation: 4813
To auto load the Modules
namespace, you need to edit your autoload section of composer.json
to look like the following:
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/",
"Modules\\": "modules/"
}
},
Then
run the following commands
php artisan clear-compiled
composer dumpautoload
composer update
Upvotes: 1