{"id":28073535,"url":"https://github.com/the-pawn-2017/r5t","last_synced_at":"2025-10-14T03:17:58.103Z","repository":{"id":247000615,"uuid":"809563216","full_name":"the-pawn-2017/r5t","owner":"the-pawn-2017","description":" Automatically generated OpenAPI 3/swagger documentation via Go code, without relying on comments","archived":false,"fork":false,"pushed_at":"2024-12-05T07:50:35.000Z","size":1321,"stargazers_count":9,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-14T03:17:55.931Z","etag":null,"topics":["api-documentation","go","golang","oauth2","openapi3","rest-api","swagger-documentation","swagger-ui"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/the-pawn-2017.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/security.go","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-06-03T02:29:55.000Z","updated_at":"2024-12-05T07:50:39.000Z","dependencies_parsed_at":"2024-07-15T02:27:33.717Z","dependency_job_id":"9e199e78-817a-420a-a420-890a77fc0a80","html_url":"https://github.com/the-pawn-2017/r5t","commit_stats":null,"previous_names":["the-pawn-2017/r5t"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/the-pawn-2017/r5t","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-pawn-2017%2Fr5t","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-pawn-2017%2Fr5t/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-pawn-2017%2Fr5t/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-pawn-2017%2Fr5t/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/the-pawn-2017","download_url":"https://codeload.github.com/the-pawn-2017/r5t/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-pawn-2017%2Fr5t/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279017790,"owners_count":26086143,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["api-documentation","go","golang","oauth2","openapi3","rest-api","swagger-documentation","swagger-ui"],"created_at":"2025-05-12T22:59:43.682Z","updated_at":"2025-10-14T03:17:58.088Z","avatar_url":"https://github.com/the-pawn-2017.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# r5t\n\n\u003e 省流版：这是一个用go 代码生成swagger/openApi文档的库，不需要写注释！;这个库基于`go-openapi`，可以嵌入到web项目中。[文档连接](https://juejin.cn/post/7390569548367822858)\n\u003e Automatically generated OpenAPI 3/swagger documentation via Go code, without relying on comments. It can be embedded in your web project.\n\ninstall: `go get -u github.com/the-pawn-2017/r5t`\n\n## why create this repo?\n1. I would like to implement more other features, such as support for GIN and ECHO.\n2. Since many of my projects after that require REST API documentation, I'm more motivated to maintain it.\n## version\nv0.5\n## todo\n- ✅ all openAPI/swagger components support and limit\n- ✅ Registering res\u0026req model,now,it can use json,form.\n- ✅ Supporting OAuth2 , only code and implicit\n- ✅ register model\n- 🚧 complete test\n- 🚧 full document for this repo\n- ✅ Support other web server,now,echo can use `r5t` by some function, it's in [`example/echo`](./example/echo/echo.md)\n\n## some useful feature\n### 1. fast pagination\n```golang\ns := r5t.NewSpec(spec.Title(\"pagination.yaml\"))\ns.Get(\"/test-pagination\").PageInQuery(\"page\", 1, \"pageSize\", 10).ResString(http.StatusOK, res.Example(\"hi\"))\n```\n### 2. easy to use for OAuth2\n```golang\ns := spec.NewSpec()\ns.Security(\n\tsecurity.WithOAuth2Code(\"ziteal\", \"http://10.45.8.189:8080/oauth/v2/authorize\", \"http://10.45.8.189:8080/oauth/v2/token\",\n\tsecurity.AddScope(\"openid\", \"OPENID IS USING FOR ID\")),\n)\n```\n### 3. concise and powerful API, like `Reqjson`,`ResJson`,`ResString`.\n```golang\ns := r5t.NewSpec(spec.Title(\"example reqString\"))\ns.Get(\"/test-resString\").ResString(http.StatusOK, res.Example(\"hi!\"))\n```\n## example:\ngo [`/test/spec_test`](/tests/spec_test.go) view some example\n```golang\ntype Test struct {\n\tA string\n\tB string `validate:\"required\"`\n}\n```\n```golang\n\ts := spec.NewSpec()\n\ts.Security(\n\t\tsecurity.WithOAuth2Code(\"ziteal\", \"http://10.45.8.189:8080/oauth/v2/authorize\", \"http://10.45.8.189:8080/oauth/v2/token\",\n\t\t\tsecurity.AddScope(\"openid\", \"OPENID IS USING FOR ID\")),\n\t)\n\t// than, you can use OAuth2 code mode now\n\ts.Post(\"/gkd\").NeedSecurify(\"ziteal\", []string{\"openid\"}).\n\t\tReqJSON(model.ModelOf[Test](), req.WithExample(Test{A: \"A\", B: \"B\"})).\n\t\tResJSON(http.StatusOK, model.ModelOf[Test](), res.WithExample(Test{A: \"A\", B: \"B\"}))\n```\n### embed swagger-ui\n\n```golang\npackage main\n\nimport (\n\t\"net/http\"\n\n\t\"github.com/labstack/echo/v4\"\n\t\"github.com/labstack/echo/v4/middleware\"\n\t\"github.com/the-pawn-2017/r5t\"\n\t\"github.com/the-pawn-2017/r5t/model\"\n\t\"github.com/the-pawn-2017/r5t/req\"\n\t\"github.com/the-pawn-2017/r5t/res\"\n\t\"github.com/the-pawn-2017/r5t/security\"\n\t\"github.com/the-pawn-2017/r5t/swaggerui\"\n)\n\ntype TestBasic struct {\n\tA string\n\tB string `validate:\"required\"`\n}\n\nfunc main() {\n\te := echo.New()\n\te.Use(middleware.Logger())\n\ts := r5t.NewSpec()\n\ts.Security(\n\t\tsecurity.OAuth2Code(\"ziteal\", \"http://10.45.8.189:8080/oauth/v2/authorize\", \"http://10.45.8.189:8080/oauth/v2/token\",\n\t\t\tsecurity.AddScope(\"openid\", \"OPENID IS USING FOR ID\")),\n\t).\n\t\tPost(\"/gkd\").NeedSecurify(\"ziteal\", []string{\"openid\"}).\n\t\tReqJSON(model.ModelOf[TestBasic](), req.Example(TestBasic{A: \"A\", B: \"B\"})).\n\t\tResJSON(http.StatusOK, model.ModelOf[TestBasic](), res.Example(TestBasic{A: \"A\", B: \"B\"}))\n\te.GET(\"/swagger-test.json\", func(c echo.Context) error {\n\t\tre, err := swaggerui.GenSpec(s)\n\t\tif err == nil {\n\t\t\treturn c.JSONBlob(http.StatusOK, re)\n\t\t} else {\n\t\t\treturn c.String(http.StatusInternalServerError, err.Error())\n\t\t}\n\t})\n\te.GET(\"/swagger/*\", func(c echo.Context) error {\n\t\tparamStr := c.Param(\"*\")\n\t\tkind, content, err := swaggerui.GetSwaggerUIFile(\"/swagger-test.json\", paramStr)\n\t\tif err == nil {\n\t\t\treturn c.Blob(http.StatusOK, kind, content)\n\t\t}\n\t\treturn c.String(http.StatusInternalServerError, err.Error())\n\t})\n\te.Start(\":2333\")\n}\n```\n\n\n[`example/echo`](./example/echo/echo.md)\n\n**CAREFULLY USE IT IN YOUR PROJECT, BECAUSE IT IN DEVELOPING**\n\n**I am currently testing with my own projects to refine R5T, expecting it to stabilize by the end of August. At that point, I will mark R5T as ready for official use, making it convenient for everyone.**\n## tools \n[swagger-ui-edit](https://editor-next.swagger.io/)\n\u003e inspired by [a-h/rest](https://github.com/a-h/rest)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthe-pawn-2017%2Fr5t","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthe-pawn-2017%2Fr5t","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthe-pawn-2017%2Fr5t/lists"}