ronasit/laravel-swagger
Generate Swagger/OpenAPI documentation for your Laravel API directly from annotations in your controllers, with automatic route discovery, a bundled UI, and support for the OpenAPI spec.
What this package is (as evidenced by 3.3): ronasit/laravel-swagger is a Laravel package that introspects application routes/controllers and produces an OpenAPI/Swagger specification, then serves an interactive docs UI. The 3.3 changelog confirms it performs static/reflective analysis of controllers (including invokable controllers and DI-bound contracts), understands Eloquent relation query parameters (with[], with_count[]), validates generated specs, and persists generated artifacts to storage drivers.
Architecture fit: Strong fit for Laravel monoliths and modular Laravel APIs where routes, controllers, and API Resources are the source of truth. It is a build-time/documentation-plane concern, not a request-path dependency — it does not sit in the hot path of the API it documents, which keeps blast radius low. Teams already on Laravel's container/route conventions get documentation "for free" relative to hand-written OpenAPI YAML, which is the core value proposition.
Integration feasibility: Low-to-moderate. Standard Composer install + config publish + a generation command; UI serving is opt-in. The 3.3 fixes materially reduce friction:
/api/v1, /api/v2) are common in Laravel; this removes a known doc-generation defect.with[]/with_count[] expansion into discrete query params (PR #198) — generated specs become accurate for relation-inclusion APIs, reducing manual spec patching.Technical risk:
SwaggerService/SwaggerSpecValidator) — the highest-impact item. Tightening validator behavior against the OpenAPI 3.0 spec can turn previously "passing" generated specs into failures. If your CI gates on spec validation, expect new failures that reflect real spec defects rather than package regressions — but the failure will appear at upgrade time, not at code-change time. Confirm whether the target is 3.0.x vs 3.1.x before committing.temp_documentation.json") — the fix implies a prior failure mode where an empty temp file could overwrite previously generated production documentation. Treat any docs-generation step that writes to a shared/production location as a destructive operation and gate it behind a spec diff.symfony/http-foundation 7.3.x, league/commonmark 2.8.x, and a dev dependency on phpoffice/phpspreadsheet (unusual for a Swagger package; likely export tooling). Confirm no transitive constraint conflicts with your Laravel/Symfony pins.Key questions:
Stack fit: Laravel-first, Composer-distributed, no runtime service dependency. Best suited to teams whose API contracts are already expressed in Laravel constructs (routes, form requests, API Resources, policies) rather than in a separate contract-first workflow. Contract-first/design-first organizations will find the package's value diminished — it derives docs from code, which inverts that workflow.
Migration path: There is no prior assessment to reconcile, so treat 3.3 as the baseline. For a team adopting or upgrading:
Compatibility: Pin explicitly. PHP 8.4 is exercised in CI (PR #175), and PHPUnit 12 support was reverted, so do not assume a PHPUnit 12 dev environment is validated. Verify symfony/http-foundation 7.3.x against your Laravel minor — Laravel 10/11 sit on Symfony 6.x/7.x lines respectively, so a hard 7.3 floor would constrain older Laravel majors. This is the single most likely install-time surprise.
Sequencing:
Maintenance: Active maintenance with visible velocity — ~30 merged PRs in this cycle, four first-time contributors (reduces single-maintainer bus factor), Dependabot enabled, and Laravel Pint adopted (PR #190) for style consistency. The trade-off is churn: PHPUnit 12 went in and out within the same release, and error-page formatting moved across four PRs. Expect frequent patch releases; budget a recurring, low-effort upgrade cadence rather than a set-and-forget dependency.
Support: Community-supported open source; no vendor SLA. For a TPM, that means the internal team owns the runbook: who regenerates docs, who triages validator failures, and what happens when an upgrade breaks generation. Assign a named owner before adoption.
Scaling: Documentation generation scales with route count, not traffic — cost is bounded and build-time. The scaling concern is organizational, not infrastructural: as the API surface grows across versions, generated output grows and spec diffs become noisy. Mitigate with per-version spec splits and deterministic output.
Failure modes to monitor:
/api/v1-style prefixes.composer update time on older Laravel majors.Ramp-up: Low for Laravel developers — no new mental model, conventions align with routes and controllers. Realistic ramp-up is under a day to first generated spec, and roughly one sprint to reach a trustworthy, CI-gated baseline given the spec-diff and validator remediation work. The non-obvious learning curve is in steering generation: adopting invokable controllers, consistent relation-loading patterns, and typed request/response definitions so the derived spec is accurate rather than merely present. That is a code-convention investment, and it is where most of the ongoing value (or debt) accrues.
Recommendation: Adopt 3.3 for teams on Laravel with code-derived API contracts. Treat the OpenAPI 3.0 validator change and the artifact-persistence fix as required regression-test targets, not incidental. Gate the docs UI and error page to non-production, and make spec generation deterministic and diffable before depending on it.
How can I help you explore Laravel packages today?