{"id":15658853,"url":"https://github.com/long2ice/fibers","last_synced_at":"2025-07-09T18:33:28.199Z","repository":{"id":53583119,"uuid":"466100035","full_name":"long2ice/fibers","owner":"long2ice","description":"Fiber + Swagger = Fibers, a web framework dedicated to providing a FastAPI-like development experience","archived":false,"fork":false,"pushed_at":"2024-05-28T03:22:36.000Z","size":851,"stargazers_count":28,"open_issues_count":2,"forks_count":5,"subscribers_count":2,"default_branch":"dev","last_synced_at":"2025-04-04T18:47:09.279Z","etag":null,"topics":["fastapi","fiber","golang","openapi","redoc","swagger","swagger-ui"],"latest_commit_sha":null,"homepage":"https://fibers.long2ice.io/docs","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/long2ice.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":"security/apikey.go","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-04T11:38:12.000Z","updated_at":"2025-03-02T12:00:04.000Z","dependencies_parsed_at":"2024-06-19T04:12:30.347Z","dependency_job_id":null,"html_url":"https://github.com/long2ice/fibers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/long2ice/fibers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/long2ice%2Ffibers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/long2ice%2Ffibers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/long2ice%2Ffibers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/long2ice%2Ffibers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/long2ice","download_url":"https://codeload.github.com/long2ice/fibers/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/long2ice%2Ffibers/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264502387,"owners_count":23618587,"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":["fastapi","fiber","golang","openapi","redoc","swagger","swagger-ui"],"created_at":"2024-10-03T13:14:13.902Z","updated_at":"2025-07-09T18:33:28.146Z","avatar_url":"https://github.com/long2ice.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fiber + Swagger = Fibers\n\n[![deploy](https://github.com/long2ice/fibers/actions/workflows/deploy.yml/badge.svg)](https://github.com/long2ice/fibers/actions/workflows/deploy.yml)\n[![Go Reference](https://pkg.go.dev/badge/github.com/long2ice/fibers.svg)](https://pkg.go.dev/github.com/long2ice/fibers)\n\n## Introduction\n\n`Fibers` is a web framework based on `Fiber` and `Swagger` inspired by [FastAPI](https://github.com/tiangolo/fastapi),\nwhich wraps `Fiber` and provides built-in swagger api docs\nand request model validation.\n\n## Why I build this project?\n\nPrevious I have used [FastAPI](https://github.com/tiangolo/fastapi), which gives me a great experience in api docs\ngeneration and api writing, because nobody like writing api docs.\n\nNow I use `Fiber` but I can't found anything like that, I found [swag](https://github.com/swaggo/swag) but which write\ndocs with comment is so stupid. So there is `Fibers`.\n\n## Requirements\n\n- Go \u003e= 1.18, because of generic usage.\n\n## Installation\n\n```shell\ngo get -u github.com/long2ice/fibers\n```\n\n## Online Demo\n\nYou can see online demo at \u003chttps://fibers.long2ice.io/docs\u003e or \u003chttps://fibers.long2ice.io/redoc\u003e.\n\n![docs](https://raw.githubusercontent.com/long2ice/fibers/dev/images/docs.png)\n![redoc](https://raw.githubusercontent.com/long2ice/fibers/dev/images/redoc.png)\n\nAnd you can see the code in [examples](https://github.com/long2ice/fibers/tree/dev/examples).\n\n## Usage\n\n### Build Swagger\n\nFirstly, build a swagger object with basic information.\n\n```go\npackage examples\n\nimport (\n  \"github.com/getkin/kin-openapi/openapi3\"\n  \"github.com/long2ice/fibers/swagger\"\n)\n\nfunc NewSwagger() *swagger.Swagger {\n  return swagger.New(\"Fibers\", \"Swagger + Fiber = Fibers\", \"0.1.0\",\n    swagger.License(\u0026openapi3.License{\n      Name: \"Apache License 2.0\",\n      URL:  \"https://github.com/long2ice/fibers/blob/dev/LICENSE\",\n    }),\n    swagger.Contact(\u0026openapi3.Contact{\n      Name:  \"long2ice\",\n      URL:   \"https://github.com/long2ice\",\n      Email: \"long2ice@gmail.com\",\n    }),\n    swagger.TermsOfService(\"https://github.com/long2ice\"),\n  )\n}\n```\n\n### Write API\n\nThen make func which is type `F func(c *fiber.Ctx, req T) error`.\n\n```go\npackage examples\n\nimport \"github.com/gofiber/fiber/v2\"\n\ntype TestQueryReq struct {\n  Name string `query:\"name\" validate:\"required\" json:\"name\" description:\"name of model\" default:\"test\"`\n}\n\nfunc TestQuery(c *fiber.Ctx, req TestQueryReq) error {\n  return c.JSON(req)\n}\n\n// TestQueryNoReq if there is no req body\nfunc TestQueryNoReq(c *fiber.Ctx) error {\n  return c.SendString(\"xxx\")\n}\n```\n\n#### All supported tags\n\n| name          | description                                                     |\n|---------------|-----------------------------------------------------------------|\n| `query`       | binding query param                                             |\n| `cookie`      | binding cookie param                                            |\n| `form`        | binding form param                                              |\n| `json`        | binding json body                                               |\n| `uri`         | binding path param                                              |\n| `header`      | binding header param                                            |\n| `validate`    | [validator](https://github.com/go-playground/validator) support |\n| `description` | swagger docs param description                                  |\n| `example`     | swagger docs param example                                      |\n| `default`     | swagger docs param default value                                |\n| `embed`       | embed struct params or body                                     |\n\nNote that the attributes in `TestQuery`? `Fibers` will validate request and inject it automatically, then you can use it\nin handler easily.\n\n### Write Router\n\nThen write router with some docs configuration and api.\n\n```go\npackage examples\n\nvar query = router.New(\n  TestQuery,\n  router.Summary(\"Test Query\"),\n  router.Description(\"Test Query Model\"),\n  router.Tags(\"Test\"),\n)\n\n// if there is no req body\nvar query = router.NewX(\n  TestQueryNoReq,\n  router.Summary(\"Test Query\"),\n  router.Description(\"Test Query Model\"),\n  router.Tags(\"Test\"),\n)\n```\n\n### Security\n\nIf you want to project your api with a security policy, you can use security, also they will be shown in swagger docs.\n\nCurrent there is five kinds of security policies.\n\n- `Basic`\n- `Bearer`\n- `ApiKey`\n- `OpenID`\n- `OAuth2`\n\n```go\npackage main\n\nvar query = router.New(\n  TestQuery,\n  router.Summary(\"Test query\"),\n  router.Description(\"Test query model\"),\n  router.Security(\u0026security.Basic{}),\n)\n```\n\nThen you can get the authentication string by `c.Locals(security.Credentials)` depending on your auth type.\n\n```go\npackage main\n\nimport \"github.com/gofiber/fiber/v2\"\n\nfunc TestQuery(c *fiber.Ctx, req TestQueryReq) error {\n  user := c.Locals(security.Credentials).(security.User)\n  fmt.Println(user)\n  return c.JSON(req)\n}\n```\n\n### Mount Router\n\nThen you can mount router in your application or group.\n\n```go\npackage main\n\nimport \"github.com/gofiber/fiber/v2\"\n\nfunc main() {\n  app := fibers.New(NewSwagger(), fiber.Config{})\n  queryGroup := app.Group(\"/query\", fibers.Tags(\"Query\"))\n  queryGroup.Get(\"\", query)\n  queryGroup.Get(\"/:id\", queryPath)\n  queryGroup.Delete(\"\", query)\n  app.Get(\"/noModel\", noModel)\n}\n\n```\n\n### Start APP\n\nFinally, start the application with routes defined.\n\n```go\npackage main\n\nimport (\n  \"github.com/gin-contrib/cors\"\n  \"github.com/gofiber/fiber/v2\"\n  \"github.com/long2ice/fibers\"\n)\n\nfunc main() {\n  app := fibers.New(NewSwagger(), fiber.Config{})\n  app.Use(\n    logger.New(),\n    recover.New(),\n    cors.New(),\n  )\n  subApp := fibers.New(NewSwagger(), fiber.Config{})\n  subApp.Get(\"/noModel\", noModel)\n  app.Mount(\"/sub\", subApp)\n  app.Use(cors.New(cors.Config{\n    AllowOrigins:     \"*\",\n    AllowMethods:     \"*\",\n    AllowHeaders:     \"*\",\n    AllowCredentials: true,\n  }))\n  queryGroup := app.Group(\"/query\", fibers.Tags(\"Query\"))\n  queryGroup.Get(\"/list\", queryList)\n  queryGroup.Get(\"/:id\", queryPath)\n  queryGroup.Delete(\"\", query)\n\n  app.Get(\"/noModel\", noModel)\n\n  formGroup := app.Group(\"/form\", fibers.Tags(\"Form\"), fibers.Security(\u0026security.Bearer{}))\n  formGroup.Post(\"/encoded\", formEncode)\n  formGroup.Put(\"\", body)\n  formGroup.Post(\"/file\", file)\n\n  log.Fatal(app.Listen(\":8080\"))\n}\n```\n\nThat's all! Now you can visit \u003chttp://127.0.0.1:8080/docs\u003e or \u003chttp://127.0.0.1:8080/redoc\u003e to see the api docs. Have\nfun!\n\n### Disable Docs\n\nIn some cases you may want to disable docs such as in production, just put `nil` to `fibers.New`.\n\n```go\napp = fibers.New(nil, fiber.Config{})\n```\n\n### SubAPP Mount\n\nIf you want to use sub application, you can mount another `SwaGin` instance to main application, and their swagger docs\nis also separate.\n\n```go\npackage main\n\nimport \"github.com/gofiber/fiber/v2\"\n\nfunc main() {\n  app := fibers.New(NewSwagger(), fiber.Config{})\n  subApp := fibers.New(NewSwagger(), fiber.Config{})\n  subApp.Get(\"/noModel\", noModel)\n  app.Mount(\"/sub\", subApp)\n}\n\n```\n\n## ThanksTo\n\n- [kin-openapi](https://github.com/getkin/kin-openapi), OpenAPI 3.0 implementation for Go (parsing, converting,\n  validation, and more).\n- [Fiber](https://github.com/gofiber/fiber), Express inspired web framework written in Go.\n\n## License\n\nThis project is licensed under the\n[Apache-2.0](https://github.com/long2ice/fibers/blob/master/LICENSE)\nLicense.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flong2ice%2Ffibers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flong2ice%2Ffibers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flong2ice%2Ffibers/lists"}