Swagger Nuxt UI for Laravel
Laravel-first package that ships offline Nuxt UI viewer assets for OpenAPI documentation.
Composer-first Laravel package for serving an offline Swagger viewer and OpenAPI JSON endpoint from your app.
Why use it
- Laravel-focused setup with minimal integration steps.
- Offline viewer assets are shipped with the package.
- Stable route contract for docs UI and schema JSON.
- Works well with
darkaonline/l5-swaggerprojects.
Installation
composer require pepperfm/swagger-nuxt-ui-for-laravel
Optional config publish:
php artisan vendor:publish --tag=swagger-ui-bridge-config
If your schema is generated via L5 Swagger:
php artisan l5-swagger:generate
Quick start
After install, open:
GET /swagger-uiGET /api/swagger-ui
Expected behavior:
/swagger-uirenders the standalone viewer page./api/swagger-uireturns OpenAPI JSON.
Routes
| Route | Purpose |
|---|---|
GET /swagger-ui | Viewer page |
GET /api/swagger-ui | OpenAPI schema JSON |
GET /swagger-ui/assets/{asset} | Offline viewer.js / viewer.css |
Schema resolution order
The package resolves the schema file in this order:
config('swagger-ui-bridge.schema_path')- L5 Swagger configured docs path
storage/api-docs/api-docs.json
Common response outcomes for schema endpoint:
200valid schema returned404schema file not found422schema JSON is invalid
Configuration highlights
Config file: config/swagger-ui-bridge.php
Key options:
enabled: enable/disable route registrationschema_path: explicit schema file pathroute.path,route.name,route.middlewareviewer.enabledviewer.titleviewer.route.path,viewer.route.name,viewer.route.middleware
Related environment variables:
SWAGGER_UI_BRIDGE_ENABLEDSWAGGER_UI_BRIDGE_SCHEMA_PATHSWAGGER_UI_BRIDGE_ROUTE_PATHSWAGGER_UI_BRIDGE_VIEWER_ENABLEDSWAGGER_UI_BRIDGE_VIEWER_TITLE
Maintainer workflow
For package maintainers (not consumer Laravel apps), viewer assets are built with Bun:
bun install
bun run build:bridge-assets
This generates viewer bundles and syncs runtime assets shipped by the package.
Troubleshooting
- If
/api/swagger-uireturns404, verify schema file generation andschema_path. - If
/api/swagger-uireturns422, validate JSON file integrity. - If viewer is blank, verify assets are reachable via
/swagger-ui/assets/viewer.jsand/swagger-ui/assets/viewer.css.