endanguyen/yaml-swagger-laravel
Laravel package that integrates Swagger/OpenAPI docs defined in YAML. Load and serve YAML-based API specifications in a Laravel app to generate interactive documentation and keep definitions versionable alongside your code.
yaml-swagger-laravel) generates read-only YAML Swagger/OpenAPI specs from Laravel routes, enabling API documentation without manual maintenance. This aligns well with developer productivity and API-first design in Laravel applications.routes/web.php, routes/api.php) and service container, reducing boilerplate.swagger.yaml) via Artisan command (php artisan swagger:generate), avoiding runtime overhead.Route::get('/users', [UserController::class, 'index'])->swaggerTag('Users')).| Risk Area | Severity | Mitigation |
|---|---|---|
| Schema Inaccuracy | Medium | Validate generated YAML against OpenAPI spec using tools like spectral. |
| Route Parsing Errors | Low | Test with complex route groups (prefixes, middleware, rate limiting). |
| Dependency Conflicts | Low | Package has minimal deps (PHP 8.0+, Laravel 8+); check for version conflicts. |
| Performance Impact | None | Static generation; negligible runtime cost. |
| Maintenance Overhead | Medium | Requires manual updates to YAML if routes change frequently. |
darkaonline/l5-swagger, zircote/swagger-php) already in use?darkaonline/l5-swagger for dynamic docs)./api/v1).post-deploy scripts (e.g., Envoyer, Deployer).main branch).boot() to inject metadata dynamically.| Feature | Compatibility |
|---|---|
| Route Groups | ✅ Supports prefixes, middleware, and namespaces. |
| API Resources | ❌ No automatic model/field mapping (manual annotations required). |
| Authentication | ⚠️ Basic support (e.g., ->middleware('auth:api')); complex schemes need work. |
| WebSockets/GraphQL | ❌ Not supported (route-based only). |
| Laravel Sanctum/Passport | ⚠️ Middleware must be manually annotated for security schemes. |
->swaggerDescription('Fetches user data')).php artisan swagger:generate).route:list to cross-check generated YAML.swagger/v1.yaml).swagger.prod.yaml) via config.| Failure Scenario | Impact | Recovery |
|---|---|---|
| Outdated YAML | Docs mismatch actual API. | Add CI checks or manual regeneration workflows. |
| Annotation Errors | Broken YAML (invalid OpenAPI). | Validate with spectral or swagger-cli. |
| Route Parsing Bugs | Missing/incorrect endpoints. | Test with complex route groups; file issues upstream. |
| Tooling Dependency | Swagger UI/Redoc breaks. | Use version-pinned tools or fallback to raw YAML. |
| No Request/Response Modeling | Incomplete specs. | Supplement with manual YAML edits or switch to dynamic tools. |
swaggerTag, swaggerDescription).How can I help you explore Laravel packages today?