{"id":13623418,"url":"https://github.com/swaggo/echo-swagger","last_synced_at":"2026-03-14T09:13:43.757Z","repository":{"id":37484501,"uuid":"95058999","full_name":"swaggo/echo-swagger","owner":"swaggo","description":"echo middleware to automatically generate RESTful API documentation with Swagger 2.0.","archived":false,"fork":false,"pushed_at":"2024-10-21T20:59:45.000Z","size":85,"stargazers_count":852,"open_issues_count":32,"forks_count":132,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-27T04:56:56.473Z","etag":null,"topics":["echo","echo-framework","golang","middleware","swagger2"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/swaggo.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-06-22T00:46:11.000Z","updated_at":"2025-04-26T15:56:49.000Z","dependencies_parsed_at":"2024-10-22T20:15:43.731Z","dependency_job_id":null,"html_url":"https://github.com/swaggo/echo-swagger","commit_stats":{"total_commits":62,"total_committers":20,"mean_commits":3.1,"dds":0.5483870967741935,"last_synced_commit":"56020475d07fb7bc62e0efe48e8bb97ac88b758b"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swaggo%2Fecho-swagger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swaggo%2Fecho-swagger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swaggo%2Fecho-swagger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swaggo%2Fecho-swagger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swaggo","download_url":"https://codeload.github.com/swaggo/echo-swagger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251089620,"owners_count":21534523,"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":["echo","echo-framework","golang","middleware","swagger2"],"created_at":"2024-08-01T21:01:31.631Z","updated_at":"2026-03-14T09:13:43.749Z","avatar_url":"https://github.com/swaggo.png","language":"Go","funding_links":[],"categories":["Go","Middlewares \u0026 framework add-ons"],"sub_categories":[],"readme":"# echo-swagger\n\necho middleware to automatically generate RESTful API documentation with Swagger 2.0.\n\n[![Build Status](https://github.com/swaggo/echo-swagger/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/features/actions)\n[![Codecov branch](https://img.shields.io/codecov/c/github/swaggo/echo-swagger/master.svg)](https://codecov.io/gh/swaggo/echo-swagger)\n[![Go Report Card](https://goreportcard.com/badge/github.com/swaggo/echo-swagger)](https://goreportcard.com/report/github.com/swaggo/echo-swagger)\n[![Release](https://img.shields.io/github/release/swaggo/echo-swagger.svg?style=flat-square)](https://github.com/swaggo/echo-swagger/releases)\n\n## Usage\n\n### Start using it\n\n1. Add comments to your API source code, [See Declarative Comments Format](https://github.com/swaggo/swag#declarative-comments-format).\n2. Download [Swag](https://github.com/swaggo/swag) for Go by using:\n\n```sh\n$ go get -d github.com/swaggo/swag/cmd/swag\n\n# 1.21 or newer\n$ go install github.com/swaggo/swag/cmd/swag@latest\n```\n\n3. Run the [Swag](https://github.com/swaggo/swag) in your Go project root folder which contains `main.go` file, [Swag](https://github.com/swaggo/swag) will parse comments and generate required files(`docs` folder and `docs/doc.go`).\n\n```sh_ \"github.com/swaggo/echo-swagger/v2/example/docs\"\n$ swag init\n```\n\n4. Download [echo-swagger](https://github.com/swaggo/echo-swagger) by using:\n\n```sh\n$ go get -u github.com/swaggo/echo-swagger\n```\n\nAnd import following in your code:\n\n```go\nimport \"github.com/swaggo/echo-swagger\" // echo-swagger middleware\n```\n\n### Canonical example:\n\n## OpenAPI Specification (OAS) 2.0\n\n```go\npackage main\n\nimport (\n\t\"github.com/labstack/echo/v5\"\n\t\"github.com/swaggo/echo-swagger/v2\"\n\n\t_ \"github.com/swaggo/echo-swagger/v2/example/docs\" // docs is generated by Swag CLI, you have to import it.\n)\n\n// @title Swagger Example API\n// @version 1.0\n// @description This is a sample server Petstore server.\n// @termsOfService http://swagger.io/terms/\n\n// @contact.name API Support\n// @contact.url http://www.swagger.io/support\n// @contact.email support@swagger.io\n\n// @license.name Apache 2.0\n// @license.url http://www.apache.org/licenses/LICENSE-2.0.html\n\n// @host petstore.swagger.io\n// @BasePath /v2\nfunc main() {\n\te := echo.New()\n\n\te.GET(\"/swagger/*\", echoSwagger.WrapHandler)\n\n\te.Logger.Fatal(e.Start(\":1323\"))\n}\n```\n\n## OpenAPI Specification (OAS) 3.0\n\n```go\npackage main\n\nimport (\n\t\"github.com/labstack/echo/v5\"\n\t\"github.com/swaggo/echo-swagger/v2\"\n\n\t_ \"github.com/swaggo/echo-swagger/v2/example/docs\" // docs is generated by Swag CLI, you have to import it.\n)\n\n// @title Swagger Example API\n// @version 1.0\n// @description This is a sample server Petstore server.\n// @termsOfService http://swagger.io/terms/\n\n// @contact.name API Support\n// @contact.url http://www.swagger.io/support\n// @contact.email support@swagger.io\n\n// @license.name Apache 2.0\n// @license.url http://www.apache.org/licenses/LICENSE-2.0.html\n\n// @host petstore.swagger.io\n// @BasePath /v2\nfunc main() {\n\te := echo.New()\n\n\te.GET(\"/swagger/*\", echoSwagger.WrapHandlerV3)\n\n\te.Logger.Fatal(e.Start(\":1323\"))\n}\n```\n\n5. Run it, and browser to http://localhost:1323/swagger/index.html, you can see Swagger 2.0 Api documents.\n\n![swagger_index.html](https://user-images.githubusercontent.com/8943871/36250587-40834072-1279-11e8-8bb7-02a2e2fdd7a7.png)\n\nNote: If you are using Gzip middleware you should add the swagger endpoint to skipper\n\n### Example\n\n```\ne.Use(middleware.GzipWithConfig(middleware.GzipConfig{\n\t\tSkipper: func(c echo.Context) bool {\n\t\t\tif strings.Contains(c.Request().URL.Path, \"swagger\") {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn false\n\t\t},\n\t}))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswaggo%2Fecho-swagger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswaggo%2Fecho-swagger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswaggo%2Fecho-swagger/lists"}