darkaonline/l5-swagger
Laravel wrapper for swagger-php and Swagger UI. Generate and serve OpenAPI/Swagger docs from annotations, with configurable routes, assets, and security (e.g., Passport). Includes config publishing, scanning paths, and an interactive docs UI.
Pros:
swagger-php (v6+) and swagger-ui, ensuring adherence to OpenAPI 3.x standards, which is critical for API documentation, tooling (e.g., Postman, Insomnia), and automated testing.#[OpenApi\...]) for declarative API documentation, reducing boilerplate and improving maintainability.Cons:
swagger-php library has a steep learning curve for custom schemas, validation, or non-standard OpenAPI features (e.g., WebSockets, Server Sent Events).Route::apiResource), middleware (e.g., auth:api), and service providers.securitySchemes in OpenAPI spec.generate_always: false).swagger-php and swagger-ui introduces upstream risks (e.g., security patches, deprecations).swagger-php’s extensibility suffice, or are custom processors needed?securitySchemes support cover your OAuth2/OpenID flows?graphql-php + custom OpenAPI extensions) or gRPC (use Protocol Buffers)./api/v1/users) to test:
#[OpenApi\Info]).laravel/framework:^11.0 in composer.json.php:8.2 in Docker or upgrade runtime.foreach with string keys).swagger-php:^6.0, symfony/yaml:^6.0, zircote/swagger-php.doctrine/annotations (deprecated in v10.0.0); use attributes instead.darkaonline/l5-passport for Passport-specific features.composer require darkaonline/l5-swagger --dev
php artisan vendor:publish --provider="OpenApi\L5Swagger\L5SwaggerServiceProvider" --tag=l5-swagger-config
php artisan vendor:publish --provider="OpenApi\L5Swagger\L5SwaggerServiceProvider" --tag=l5-swagger-assets
.env:
L5_SWAGGER_FORMAT=json
L5_SWAGGER_UI_ASSETS_PATH=/vendor/darkaonline/l5-swagger/public
config/l5-swagger.php:
'api' => [
'title' => 'Your API',
'description' => 'API Documentation',
'version' => '1.0.0',
'security' => ['bearerAuth' => []],
],
'security' => [
'components' => [
'securitySchemes' => [
'bearerAuth' => [
'type' => 'http',
'scheme' => 'bearer',
'bearerFormat' => 'JWT',
],
],
],
],
use OpenApi\Attributes as OA;
How can I help you explore Laravel packages today?