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-swagger projects.

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-ui
  • GET /api/swagger-ui

Expected behavior:

  • /swagger-ui renders the standalone viewer page.
  • /api/swagger-ui returns OpenAPI JSON.

Routes

RoutePurpose
GET /swagger-uiViewer page
GET /api/swagger-uiOpenAPI schema JSON
GET /swagger-ui/assets/{asset}Offline viewer.js / viewer.css

Schema resolution order

The package resolves the schema file in this order:

  1. config('swagger-ui-bridge.schema_path')
  2. L5 Swagger configured docs path
  3. storage/api-docs/api-docs.json

Common response outcomes for schema endpoint:

  • 200 valid schema returned
  • 404 schema file not found
  • 422 schema JSON is invalid

Configuration highlights

Config file: config/swagger-ui-bridge.php

Key options:

  • enabled: enable/disable route registration
  • schema_path: explicit schema file path
  • route.path, route.name, route.middleware
  • viewer.enabled
  • viewer.title
  • viewer.route.path, viewer.route.name, viewer.route.middleware

Related environment variables:

  • SWAGGER_UI_BRIDGE_ENABLED
  • SWAGGER_UI_BRIDGE_SCHEMA_PATH
  • SWAGGER_UI_BRIDGE_ROUTE_PATH
  • SWAGGER_UI_BRIDGE_VIEWER_ENABLED
  • SWAGGER_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-ui returns 404, verify schema file generation and schema_path.
  • If /api/swagger-ui returns 422, validate JSON file integrity.
  • If viewer is blank, verify assets are reachable via /swagger-ui/assets/viewer.js and /swagger-ui/assets/viewer.css.

Resources