binarytorch/larecipe-swagger
Adds Swagger/OpenAPI support to LaRecipe documentation sites, letting Laravel apps render interactive API reference pages from OpenAPI specs alongside their existing docs.
This package is an add-on to LaRecipe (binarytorch/larecipe). It renders an interactive Swagger UI panel inside a LaRecipe documentation page so readers can execute "Try it out" requests against your API without leaving /docs. It does nothing on its own — install LaRecipe first.
Minimal path:
composer require binarytorch/larecipe-swaggerphp artisan vendor:publish --provider="BinaryTorch\LaRecipeSwagger\LaRecipeSwaggerServiceProvider"public/docs/openapi.json, or a route returning the JSON).resources/docs/, add a fenced swagger code block containing the spec path/URL (the README shows the exact block shape — copy it verbatim, including blank lines).Look first at: the package README, its published config (spec URL / base path options), the published views/blade partial it injects, and the bundled swagger-ui asset version (this tells you whether OpenAPI 3.0 is supported or only Swagger 2.0).
First real use case: a "Reference" or "Playground" docs page where each endpoint has a prose explanation in Markdown followed by a swagger block scoped to that endpoint's spec.
curl examples; use the swagger block only for the interactive part. Readers with JS disabled or a blocked network still get the docs./api/docs/openapi.json produced by your serializer or a committed export step. A checked-in openapi.json drifts within weeks; a route keeps it honest, at the cost of the docs page depending on app health.Authorization header, and avoid wildcard origins with credentials.host/basePath (Swagger 2.0) or servers (OAS3) to a local or staging URL. This is the single most useful knob: it lets the docs stay useful in dev without letting anyone fire writes at production.php artisan tinker into the Authorize box") rather than expecting it to carry over.swagger-cli validate or Spectral against the spec. The UI degrades quietly on malformed specs — a green CI check is cheaper than debugging a blank panel.php artisan config:clear and LaRecipe's docs cache clear (often php artisan larecipe:clear) after editing config, assets, or specs.web middleware stack will fail with 419. Target api routes with token auth, or whitelist the docs origin explicitly.DELETE. Guard the docs behind LaRecipe's auth/gate plus an IP allowlist, and never ship it enabled in production.swagger-ui determines this. If OAS3 renders blank, either downgrade the spec or replace the bundled swagger-ui dist — that's the main extension point.basePath/servers mismatch produces 404s that look like auth failures. Confirm the final request URL in the Network tab matches your route.swagger-ui build. Beyond that, fork — the upstream is dormant.swagger-ui; you get current OAS3 support and a maintained dependency for less effort than resurrecting this one.How can I help you explore Laravel packages today?