{"id":15489493,"url":"https://github.com/harmbandstra/swagger-ui-bundle","last_synced_at":"2025-05-07T09:45:44.735Z","repository":{"id":44907461,"uuid":"83016584","full_name":"harmbandstra/swagger-ui-bundle","owner":"harmbandstra","description":"Expose swagger-ui inside your symfony project through a route (eg. /docs) for viewing your OpenAPI spec.","archived":false,"fork":false,"pushed_at":"2023-04-21T07:41:43.000Z","size":1103,"stargazers_count":40,"open_issues_count":0,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-03T09:43:49.882Z","etag":null,"topics":["openapi","php","swagger-ui","symfony","symfony-bundle"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/harmbandstra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-24T07:58:29.000Z","updated_at":"2025-03-27T12:49:17.000Z","dependencies_parsed_at":"2024-06-19T01:54:57.549Z","dependency_job_id":null,"html_url":"https://github.com/harmbandstra/swagger-ui-bundle","commit_stats":{"total_commits":93,"total_committers":7,"mean_commits":"13.285714285714286","dds":"0.17204301075268813","last_synced_commit":"5265366c5196d5348c65b2e7b0598df50bd8b1c3"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmbandstra%2Fswagger-ui-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmbandstra%2Fswagger-ui-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmbandstra%2Fswagger-ui-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmbandstra%2Fswagger-ui-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harmbandstra","download_url":"https://codeload.github.com/harmbandstra/swagger-ui-bundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252854182,"owners_count":21814643,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["openapi","php","swagger-ui","symfony","symfony-bundle"],"created_at":"2024-10-02T07:06:05.993Z","updated_at":"2025-05-07T09:45:44.712Z","avatar_url":"https://github.com/harmbandstra.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.com/harmbandstra/swagger-ui-bundle.svg?branch=master)](https://travis-ci.com/harmbandstra/swagger-ui-bundle)\n[![Code Coverage](https://scrutinizer-ci.com/g/harmbandstra/swagger-ui-bundle/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/harmbandstra/swagger-ui-bundle/?branch=master)\n\n# Swagger UI Bundle\n\nExpose 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.\n\nJust add a reference to your OpenAPI Yaml or JSON specification, and enjoy swagger-ui in all it's glory.\n\nAfter 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).\n\n## Compatibility\n\n* If you need symfony 2.3 - 2.6 support, use version 1.x.\n* If you need symfony 2.7 - 3.x support, or php 5.x use version 2.x.\n* For symfony 3.3 and later with PHP \u003e 7.0 use version 3.x.\n* For symfony 4.0 and later with PHP =\u003e 7.1.3 use version 4.x.\n* For PHP \u003e 8.0 user version \u003e 4.4\n\n**NOTE** Since version 3.1, support for symfony 4 on the 3.x branch has been dropped. Use the 4.x branch instead.\n\n## Installation\n\nInstall with composer in dev environment:\n\n`$ composer require harmbandstra/swagger-ui-bundle --dev`\n\nMake 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`.\n\n```json\n{\n  \"scripts\": {\n    \"symfony-scripts\": [\n        \"HarmBandstra\\\\SwaggerUiBundle\\\\Composer\\\\ScriptHandler::linkAssets\",\n        \"Sensio\\\\Bundle\\\\DistributionBundle\\\\Composer\\\\ScriptHandler::installAssets\"\n    ],\n    \"post-install-cmd\": [\"@symfony-scripts\"],\n    \"post-update-cmd\": [\"@symfony-scripts\"]\n}\n```\n\nIf the `scripts` section in composer.json looks like this (symfony 4):\n```json\n    \"scripts\": {\n        \"auto-scripts\": {\n            \"cache:clear\": \"symfony-cmd\",\n            \"assets:install %PUBLIC_DIR%\": \"symfony-cmd\"\n        },\n        \"post-install-cmd\": [\n            \"@auto-scripts\"\n        ],\n        \"post-update-cmd\": [\n            \"@auto-scripts\"\n        ]\n    },\n```\n\nAdd the composer hook like this:\n```json\n    \"scripts\": {\n        \"auto-scripts\": {\n            \"cache:clear\": \"symfony-cmd\",\n            \"assets:install %PUBLIC_DIR%\": \"symfony-cmd\"\n        },\n        \"post-install-cmd\": [\n            \"HarmBandstra\\\\SwaggerUiBundle\\\\Composer\\\\ScriptHandler::linkAssets\",\n            \"@auto-scripts\"\n        ],\n        \"post-update-cmd\": [\n            \"HarmBandstra\\\\SwaggerUiBundle\\\\Composer\\\\ScriptHandler::linkAssets\",\n            \"@auto-scripts\"\n        ]\n    },\n```\n\nEnable bundle in `app/AppKernel.php`(Symfony 3):\n\n```php\n\u003c?php\n\nclass AppKernel extends Kernel\n{\n    public function registerBundles()\n    {\n        // ...\n\n        if (in_array($this-\u003egetEnvironment(), ['dev', 'test'], true)) {\n            // ...\n            $bundles[] = new HarmBandstra\\SwaggerUiBundle\\HBSwaggerUiBundle();\n        }\n\n        // ...\n    }\n}\n```\n\nEnable bundle in `config/bundles.php`(Symfony 4):\n```php\n\u003c?php\n\nreturn [\n    // ...\n    HarmBandstra\\SwaggerUiBundle\\HBSwaggerUiBundle::class =\u003e ['dev' =\u003e true]\n];\n```\nAdd the route where swagger-ui will be available in `routing_dev.yml`:\n\n```yml\n_swagger-ui:\n    resource: '@HBSwaggerUiBundle/Resources/config/routing.yml'\n    prefix: /docs\n```\n\n## Configuration (Symfony 3)\n\nIn your `config.yml`, link to the swagger spec.\n\nSpecify the `directory` where your swagger files reside. You can access multiple files through the endpoint like `/docs/my_swagger_spec.json`.\nUnder `files` you specify which files should be exposed.\n\nThe first file in the array is the default one and it will be the file the `/docs` endpoint will redirect to. For this file you have the option to specify an absolute path to the .json spec file (\"/_swagger/swagger.json\") or a URL (\"https://example.com/swagger.json\").\n\n```yaml\nhb_swagger_ui:\n  directory: \"%kernel.root_dir%/../docs/\"\n  files:\n    - \"/_swagger/swagger.json\"\n    - \"my_swagger_spec.yml\"\n    - \"my_other_swagger_spec.json\"\n```\n\nOptional: If you want to have a default configuration in place for Swagger UI, place a `config.json` in the same directory as the swagger files, and add it to the configuration. It will be loaded automatically by appending it as the query parameter `configUrl`.\n\n```yaml\nhb_swagger_ui:\n  configFile: \"config.json\"\n```\n\nOptional: If you serve your project from a different directory than the vhost root, you can overwrite the asset URL path with the `assetUrlPath` configuration. Be sure to add a leading and trailing slash.\n\n```yaml\nhb_swagger_ui:\n  assetUrlPath: '/my-vhost-sub-directory/bundles/hbswaggerui/'\n```\n\n## Configuration (Symfony 4, 5 and 6)\n\nCreate a file `hb_swagger_ui.yaml` `in config/packages`. Follow the rest of the steps for configuration in Symfony 3.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharmbandstra%2Fswagger-ui-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharmbandstra%2Fswagger-ui-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharmbandstra%2Fswagger-ui-bundle/lists"}