PHPackages                             hypecodeteam/swagger-ui-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. hypecodeteam/swagger-ui-bundle

ActiveSymfony-bundle[API Development](/categories/api)

hypecodeteam/swagger-ui-bundle
==============================

Exposes swagger UI inside your Symfony project through a route (eg. /docs)

6.0.2(9mo ago)01.7kGPL-3.0-or-laterPHPPHP ^7.4 || ^8.0

Since Dec 6Pushed 9mo agoCompare

[ Source](https://github.com/HypeCodeTeam/swagger-ui-bundle)[ Packagist](https://packagist.org/packages/hypecodeteam/swagger-ui-bundle)[ Docs](https://github.com/harmbandstra/swagger-ui-bundle)[ RSS](/packages/hypecodeteam-swagger-ui-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (11)Versions (15)Used By (0)

[![Build Status](https://camo.githubusercontent.com/5844a53245893ffe16c43dd6632065cddf6cf5bd620a0a68c1fce3b71d002c03/68747470733a2f2f7472617669732d63692e636f6d2f6861726d62616e64737472612f737761676765722d75692d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/harmbandstra/swagger-ui-bundle)[![Code Coverage](https://camo.githubusercontent.com/134419cd123b31b472e3f32404a9dee812d9a93234e5b0fa56f81ac3cabdbc40/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6861726d62616e64737472612f737761676765722d75692d62756e646c652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/harmbandstra/swagger-ui-bundle/?branch=master)

Swagger UI Bundle
=================

[](#swagger-ui-bundle)

Expose swagger-ui inside your symfony project through a route (eg. /docs), just like [nelmio api docs](https://github.com/nelmio/NelmioApiDocBundle), without the need for node.

Just add a reference to your OpenAPI Yaml or JSON specification, and enjoy swagger-ui in all it's glory.

After installation and configuration, just start your local webserver, and navigate to [/docs](http://127.0.0.1:8000/docs) or [/docs/my\_swagger\_spec.yml](http://127.0.0.1:8000/docs/my_swagger_spec.yml).

Compatibility
-------------

[](#compatibility)

- If you need symfony 2.3 - 2.6 support, use version 1.x.
- If you need symfony 2.7 - 3.x support, or php 5.x use version 2.x.
- For symfony 3.3 and later with PHP &gt; 7.0 use version 3.x.
- For symfony 4.0 and later with PHP =&gt; 7.1.3 use version 4.x.
- For PHP &gt; 8.0 user version &gt; 4.4

**NOTE** Since version 3.1, support for symfony 4 on the 3.x branch has been dropped. Use the 4.x branch instead.

Installation
------------

[](#installation)

Install with composer in dev environment:

`$ composer require harmbandstra/swagger-ui-bundle --dev`

Make sure swagger-ui assets are copied to `web/bundles` by adding the [`HarmBandstra\SwaggerUiBundle\Composer\ScriptHandler::linkAssets`](src/Composer/ScriptHandler#L13) composer hook **before** the [`Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets`](https://github.com/sensiolabs/SensioDistributionBundle/blob/master/Composer/ScriptHandler.php#L158) hook in your `composer.json`.

```
{
  "scripts": {
    "symfony-scripts": [
        "HarmBandstra\\SwaggerUiBundle\\Composer\\ScriptHandler::linkAssets",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets"
    ],
    "post-install-cmd": ["@symfony-scripts"],
    "post-update-cmd": ["@symfony-scripts"]
}
```

If the `scripts` section in composer.json looks like this (symfony 4):

```
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
```

Add the composer hook like this:

```
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "HarmBandstra\\SwaggerUiBundle\\Composer\\ScriptHandler::linkAssets",
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "HarmBandstra\\SwaggerUiBundle\\Composer\\ScriptHandler::linkAssets",
            "@auto-scripts"
        ]
    },
```

Enable bundle in `app/AppKernel.php`(Symfony 3):

```
