Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Swagger Ui Laravel Package

swagger-api/swagger-ui

Swagger UI renders interactive API docs from OpenAPI/Swagger specs. Explore endpoints, send requests, and view responses in the browser without backend implementation. Available as npm modules or Docker/Packagist distributions for easy hosting and integration.

View on GitHub
Deep Wiki
Context7

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.

Frequently asked questions about Swagger Ui
How do I integrate Swagger UI with a Laravel API that doesn’t use darkaonline/l5-swagger?
Generate an OpenAPI spec manually by defining a JSON/YAML file (e.g., `public/api-docs/openapi.json`) or use Laravel’s `routes/api.php` to output the spec dynamically. Swagger UI only requires a valid OpenAPI 2.0/3.x spec to render. Validate your spec using the [Swagger Editor](https://editor.swagger.io/) before deploying.
Can Swagger UI work with Laravel Sanctum or Passport for OAuth2 authentication?
Yes. Configure Swagger UI’s OAuth2 settings in the JavaScript bundle to match your Sanctum/Passport endpoints. Set `oauth2RedirectUrl` and `clientId`/`clientSecret` in the `SwaggerUIBundle` config. Ensure your Laravel API includes CORS headers for the Swagger UI domain to avoid authentication failures.
What’s the easiest way to deploy Swagger UI for a Laravel project?
Use `swagger-ui-dist` by copying its `/dist` files to `public/swagger-ui` in your Laravel project. Add a simple HTML file (e.g., `public/swagger.html`) with the JavaScript bundle and CSS links, then point it to your OpenAPI spec URL. No npm or build tools required.
Does Swagger UI support Laravel’s API versioning (e.g., `/api/v1/docs`)?
Yes. Host multiple OpenAPI specs at different paths (e.g., `/api/v1/openapi.json`, `/api/v2/openapi.json`) and configure Swagger UI to load the correct spec URL dynamically. Use URL parameters or dropdowns in your Swagger UI config to switch between versions.
Will Swagger UI slow down my Laravel application in production?
Swagger UI is a static asset or standalone service, so it won’t impact Laravel’s backend performance. However, large OpenAPI specs may slow down rendering. Optimize by enabling `deepLinking: false` or lazy-loading specs. For Docker deployments, use the official `swaggerapi/swagger-ui` image to isolate resources.
How do I customize Swagger UI’s appearance for my Laravel project?
Override Swagger UI’s CSS by adding custom stylesheets or use the `presets` option in the JavaScript bundle. For advanced theming, clone the `swagger-ui` repo and modify the source files, then rebuild with npm. Alternatively, use the `layout` and `deepLinking` config options to adjust UI behavior.
Can I use Swagger UI with Laravel Vite or Mix for asset bundling?
Yes. Install `swagger-ui` via npm (`npm install swagger-ui`) and import it in your Vite/Mix entry file. Configure the bundle in your JavaScript like `SwaggerUIBundle({ url: '/api-docs/openapi.json' })`. Ensure your Laravel build process includes the Swagger UI dependencies.
What Laravel versions are compatible with Swagger UI?
Swagger UI itself has no Laravel dependency—it works with any Laravel version (5.8+) as long as your API generates a valid OpenAPI spec. Test with Laravel 8/9/10 for full compatibility with `darkalonline/l5-swagger` or manual spec generation. PHP 7.4+ is recommended for optimal performance.
How do I test Swagger UI locally during Laravel development?
Run `php artisan serve` and access your OpenAPI spec (e.g., `http://localhost:8000/api-docs/openapi.json`). Serve Swagger UI’s static files from `public/swagger-ui` or use a local npm dev server. For OAuth2 testing, mock tokens in Swagger UI’s `authorizations` config or use Laravel’s Sanctum/Passport test helpers.
Are there alternatives to Swagger UI for Laravel API documentation?
Yes. For static docs, consider [Redoc](https://redocly.github.io/redoc/) (lighter, less interactive) or [Postman’s API Network](https://learning.postman.com/docs/integrations/api-network/) (better for team collaboration). For Laravel-specific tools, `darkalonline/l5-swagger` generates specs, but Swagger UI provides the best interactive experience for API consumers.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/user-bundle
codraw/tester-bundle
codraw/sonata-integration-bundle
codraw/sonata-extra-bundle
codraw/console
codraw/application
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk